001/*
002 * The contents of this file are subject to the license and copyright
003 * detailed in the LICENSE and NOTICE files at the root of the source
004 * tree.
005 */
006package org.fcrepo.kernel.impl.operations;
007
008import org.apache.jena.rdf.model.Model;
009
010import org.fcrepo.config.ServerManagedPropsMode;
011import org.fcrepo.kernel.api.RdfStream;
012import org.fcrepo.kernel.api.Transaction;
013import org.fcrepo.kernel.api.identifiers.FedoraId;
014import org.fcrepo.kernel.api.operations.CreateRdfSourceOperation;
015import org.fcrepo.kernel.api.operations.CreateRdfSourceOperationBuilder;
016
017/**
018 * Builder for operations to create rdf sources
019 *
020 * @author bbpennel
021 */
022public class CreateRdfSourceOperationBuilderImpl extends AbstractRdfSourceOperationBuilder implements
023        CreateRdfSourceOperationBuilder {
024
025    private FedoraId parentId;
026
027    private boolean archivalGroup = false;
028    /**
029     * Constructor.
030     *
031     * @param transaction the transaction
032     * @param resourceId the internal identifier.
033     * @param interactionModel interaction model
034     * @param serverManagedPropsMode server managed props mode
035     */
036    public CreateRdfSourceOperationBuilderImpl(final Transaction transaction, final FedoraId resourceId,
037                                               final String interactionModel,
038                                               final ServerManagedPropsMode serverManagedPropsMode) {
039        super(transaction, resourceId, interactionModel, serverManagedPropsMode);
040    }
041
042    @Override
043    public CreateRdfSourceOperation build() {
044        final var operation = new CreateRdfSourceOperationImpl(transaction, rescId, interactionModel, tripleStream);
045        operation.setParentId(parentId);
046        operation.setUserPrincipal(userPrincipal);
047        operation.setCreatedBy(createdBy);
048        operation.setCreatedDate(createdDate);
049        operation.setLastModifiedBy(lastModifiedBy);
050        operation.setLastModifiedDate(lastModifiedDate);
051        operation.setArchivalGroup(archivalGroup);
052        return operation;
053    }
054
055    @Override
056    public CreateRdfSourceOperationBuilder userPrincipal(final String userPrincipal) {
057        super.userPrincipal(userPrincipal);
058        return this;
059    }
060
061    @Override
062    public CreateRdfSourceOperationBuilder triples(final RdfStream triples) {
063        super.triples(triples);
064        return this;
065    }
066
067    @Override
068    public CreateRdfSourceOperationBuilder parentId(final FedoraId parentId) {
069        this.parentId = parentId;
070        return this;
071    }
072
073    @Override
074    public CreateRdfSourceOperationBuilder relaxedProperties(final Model model) {
075        super.relaxedProperties(model);
076        return this;
077    }
078
079    @Override
080    public CreateRdfSourceOperationBuilder archivalGroup(final boolean flag) {
081        this.archivalGroup = flag;
082        return this;
083    }
084
085}