<commit_before>/*
 * Copyright 2017 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.gov.gchq.gaffer.doc.operation;

import uk.gov.gchq.gaffer.data.element.Element;
import uk.gov.gchq.gaffer.data.elementdefinition.view.View;
import uk.gov.gchq.gaffer.operation.OperationChain;
import uk.gov.gchq.gaffer.operation.OperationException;
import uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph;
import uk.gov.gchq.gaffer.operation.impl.get.GetAllElements;

public class ExportToOtherAuthorisedGraphExample extends OperationExample {
    public static void main(final String[] args) throws OperationException {
        new ExportToOtherAuthorisedGraphExample().run();
    }

    public ExportToOtherAuthorisedGraphExample() {
        super(ExportToOtherAuthorisedGraph.class, "These export examples export all edges in the example graph to another Gaffer instance using Operation Auths against the user. \n\n" +
                "To add this operation to your Gaffer graph you will need to include the ExportToOtherAuthorisedGraphOperationDeclarations.json in your store properties, i.e. set this property: " +
                "gaffer.store.operation.declarations=ExportToOtherAuthorisedGraphOperationDeclarations.json\n");
    }

    @Override
    public void runExamples() {
        simpleExport();
    }

    public void simpleExport() {

        // ---------------------------------------------------------
        final OperationChain<Iterable<? extends Element>> opChain =
                new OperationChain.Builder()
                        .first(new GetAllElements.Builder()
                                .view(new View.Builder()
                                        .edge("edge")
                                        .build())
                                .build())
                        .then(new ExportToOtherAuthorisedGraph.Builder()
                                .graphId("newGraphId")
                                .build())
                        .build();
        // ---------------------------------------------------------

        showExample(opChain, "This example will export all Edges with group 'edge' to another Gaffer graph with new ID 'newGraphId'. " +
                "The new graph will have the same schema and same store properties as the current graph. " +
                "In this case it will just create another table in accumulo called 'newGraphId'. " +
                "It will also compare the running users Operation authorisations to the authorisations supplied to the exporter.");
    }
}<commit_msg>gh-1085 - added extra example using parentIds<commit_after>/*
 * Copyright 2017 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package uk.gov.gchq.gaffer.doc.operation;

import uk.gov.gchq.gaffer.data.element.Element;
import uk.gov.gchq.gaffer.data.elementdefinition.view.View;
import uk.gov.gchq.gaffer.operation.OperationChain;
import uk.gov.gchq.gaffer.operation.OperationException;
import uk.gov.gchq.gaffer.operation.export.graph.ExportToOtherAuthorisedGraph;
import uk.gov.gchq.gaffer.operation.impl.get.GetAllElements;

public class ExportToOtherAuthorisedGraphExample extends OperationExample {
    public static void main(final String[] args) throws OperationException {
        new ExportToOtherAuthorisedGraphExample().run();
    }

    public ExportToOtherAuthorisedGraphExample() {
        super(ExportToOtherAuthorisedGraph.class, "These export examples export all edges in the example graph to another Gaffer instance using Operation Auths against the user. \n\n" +
                "To add this operation to your Gaffer graph you will need to include the ExportToOtherAuthorisedGraphOperationDeclarations.json in your store properties, i.e. set this property: " +
                "gaffer.store.operation.declarations=ExportToOtherAuthorisedGraphOperationDeclarations.json\n");
    }

    @Override
    public void runExamples() {
        simpleExport();
        simpleExportUsingParentIds();
    }

    public void simpleExport() {

        // ---------------------------------------------------------
        final OperationChain<Iterable<? extends Element>> opChain =
                new OperationChain.Builder()
                        .first(new GetAllElements.Builder()
                                .view(new View.Builder()
                                        .edge("edge")
                                        .build())
                                .build())
                        .then(new ExportToOtherAuthorisedGraph.Builder()
                                .graphId("newGraphId")
                                .build())
                        .build();
        // ---------------------------------------------------------

        showExample(opChain, "This example will export all Edges with group 'edge' to another Gaffer graph with new ID 'newGraphId'. " +
                "The new graph will have the same schema and same store properties as the current graph. " +
                "In this case it will just create another table in accumulo called 'newGraphId'. " +
                "It will also compare the running users Operation authorisations to the authorisations supplied to the exporter.");
    }

    public void simpleExportUsingParentIds() {

        // ---------------------------------------------------------
        final OperationChain<Iterable<? extends Element>> opChain =
                new OperationChain.Builder()
                        .first(new GetAllElements.Builder()
                                .view(new View.Builder()
                                        .edge("edge")
                                        .build())
                                .build())
                        .then(new ExportToOtherAuthorisedGraph.Builder()
                                .graphId("newGraphId")
                                .parentStorePropertiesId("storePropsId1")
                                .parentSchemaId("schemaId1")
                                .build())
                        .build();
        // ---------------------------------------------------------

        showExample(opChain, "This example will export all Edges with group 'edge' to another Gaffer graph with new ID 'newGraphId'. " +
                "The new graph will have a parent Schema and Store Properties within the graph library specifed by the ID's. " +
                "It will also compare the running users Operation authorisations to the authorisations supplied to the exporter.");
    }
}
{'fraction_non_alphanumeric': 0.11739187590377284, 'fraction_numerical': 0.002892073090574471, 'mean_word_length': 1.8741972043823196, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6652288', 'n_tokens_mistral': 1791, 'n_tokens_neox': 1690, 'n_words': 583}