Search in sources :

Example 6 with RowFilter

use of au.gov.asd.tac.constellation.plugins.importexport.RowFilter in project constellation by constellation-app.

the class ImportDelimitedPlugin method processVertices.

private static int processVertices(ImportDefinition definition, GraphWriteMethods graph, List<String[]> data, AttributeType attributeType, boolean initialiseWithSchema, PluginInteraction interaction, String source) throws InterruptedException {
    final List<ImportAttributeDefinition> attributeDefinitions = definition.getDefinitions(attributeType);
    addAttributes(graph, GraphElementType.VERTEX, attributeDefinitions);
    int currentRow = 0;
    int importedRows = 0;
    final int totalRows = data.size() - definition.getFirstRow();
    final RowFilter filter = definition.getRowFilter();
    for (int i = definition.getFirstRow(); i < data.size(); i++) {
        interaction.setProgress(++currentRow, totalRows, "Importing Vertices: " + source, true);
        final String[] row = data.get(i);
        if (filter == null || filter.passesFilter(i - 1, row)) {
            // Count the number of processed rows to notify in the status message
            ++importedRows;
            final int vertexId = graph.addVertex();
            for (final ImportAttributeDefinition attributeDefinition : attributeDefinitions) {
                attributeDefinition.setValue(graph, vertexId, row, (i - 1));
            }
            if (initialiseWithSchema && graph.getSchema() != null) {
                graph.getSchema().completeVertex(graph, vertexId);
            }
        }
    }
    return importedRows;
}
Also used : ImportAttributeDefinition(au.gov.asd.tac.constellation.plugins.importexport.ImportAttributeDefinition) RowFilter(au.gov.asd.tac.constellation.plugins.importexport.RowFilter)

Aggregations

ImportAttributeDefinition (au.gov.asd.tac.constellation.plugins.importexport.ImportAttributeDefinition)6 RowFilter (au.gov.asd.tac.constellation.plugins.importexport.RowFilter)6 Attribute (au.gov.asd.tac.constellation.graph.Attribute)2 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)2 AttributeType (au.gov.asd.tac.constellation.plugins.importexport.AttributeType)2 ImportDefinition (au.gov.asd.tac.constellation.plugins.importexport.ImportDefinition)2 NewAttribute (au.gov.asd.tac.constellation.plugins.importexport.NewAttribute)2 SchemaDestination (au.gov.asd.tac.constellation.plugins.importexport.SchemaDestination)2 AttributeTranslator (au.gov.asd.tac.constellation.plugins.importexport.translator.AttributeTranslator)2 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ImportFileParser (au.gov.asd.tac.constellation.plugins.importexport.delimited.parser.ImportFileParser)1 NotifyDescriptor (org.openide.NotifyDescriptor)1