Java Code Examples for org.apache.tinkerpop.gremlin.structure.Property#key()

The following examples show how to use org.apache.tinkerpop.gremlin.structure.Property#key() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileMappingGraphChangedListener.java    From windup with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void vertexPropertyChanged(Vertex element, Property oldValue, Object setValue, Object... vertexPropertyKeyValues)
{
    String key = oldValue.key();

    if (!FileModel.FILE_PATH.equals(key))
        return;

    FileService fileService = new FileService(event.getGraphContext());
    // Reload it to make sure that we have one that is attached to the graph
    element = event.getGraphContext().getGraph().vertices(element.id()).next();

    FileModel model = fileService.frame(element);

    if (model.isDirectory())
        return;

    Map<String, List<Class<? extends WindupVertexFrame>>> mappings = FileMapping.getMappings(event);

    // Compare the value being set to "fileType" against file mapping patterns.
    // If it matches, add the vertex types to this vertex.
    for (Entry<String, List<Class<? extends WindupVertexFrame>>> entry : mappings.entrySet())
    {
        String pattern = entry.getKey();
        List<Class<? extends WindupVertexFrame>> types = entry.getValue();

        if (((String) setValue).matches(pattern))
        {
            for (Class<? extends WindupVertexFrame> type : types)
            {
                GraphService.addTypeToModel(event.getGraphContext(), model, type);
            }
            LOG.fine("Mapped file [" + model.getFilePath() + "] matching pattern [" + pattern + "] "
                        + "to the following [" + types.size() + "] types: " + types);
        }
    }
}
 
Example 2
Source File: DetachedProperty.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
protected DetachedProperty(final Property<V> property) {
    this.key = property.key();
    this.value = property.value();
    this.element = DetachedFactory.detach(property.element(), false);
}
 
Example 3
Source File: ReferenceProperty.java    From tinkerpop with Apache License 2.0 4 votes vote down vote up
public ReferenceProperty(final Property<V> property) {
    this.element = null == property.element() ? null : ReferenceFactory.detach(property.element());
    this.key = property.key();
    this.value = property.value();
}
 
Example 4
Source File: ArchiveIdentificationGraphChangedListener.java    From windup with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void vertexPropertyChanged(Vertex element, Property oldValue, Object setValue, Object... vertexPropertyKeyValues)
{
    String key = oldValue.key();
    if (ArchiveModel.ARCHIVE_NAME.equals(key))
    {
        ArchiveModel archive = archiveService.getById(element.id());

        setArchiveHashes(archive);

        Coordinate coordinate = identifier.getCoordinate(archive.getSHA1Hash());
        if (coordinate != null)
        {
            // If this is not a jar file, do not ignore it
            if (!StringUtils.endsWithIgnoreCase(archive.getFileName(), ".jar"))
                return;

            // Never ignore the input application
            WindupConfigurationModel configurationModel = WindupConfigurationService.getConfigurationModel(this.context);
            for (FileModel inputPath : configurationModel.getInputPaths())
            {
                if (inputPath.equals(archive))
                    return;
            }

            IdentifiedArchiveModel identifiedArchive = GraphService.addTypeToModel(context, archive, IdentifiedArchiveModel.class);
            ArchiveCoordinateModel coordinateModel = new GraphService<>(context, ArchiveCoordinateModel.class).create();

            coordinateModel.setArtifactId(coordinate.getArtifactId());
            coordinateModel.setGroupId(coordinate.getGroupId());
            coordinateModel.setVersion(coordinate.getVersion());
            coordinateModel.setClassifier(coordinate.getClassifier());
            identifiedArchive.setCoordinate(coordinateModel);

            LOG.info("Identified archive: [" + archive.getFilePath() + "] as [" + coordinate + "] will not be unzipped or analyzed.");
            IgnoredArchiveModel ignoredArchive = GraphService.addTypeToModel(context, archive, IgnoredArchiveModel.class);
            ignoredArchive.setIgnoredRegex("Known open-source library");
        }
        else
        {
            LOG.info("Archive not identified: " + archive.getFilePath() + " SHA1: " + archive.getSHA1Hash());
        }
    }
}