当前位置: 首页>>代码示例>>Java>>正文


Java TransformFunctionPipe类代码示例

本文整理汇总了Java中com.tinkerpop.pipes.transform.TransformFunctionPipe的典型用法代码示例。如果您正苦于以下问题:Java TransformFunctionPipe类的具体用法?Java TransformFunctionPipe怎么用?Java TransformFunctionPipe使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TransformFunctionPipe类属于com.tinkerpop.pipes.transform包,在下文中一共展示了TransformFunctionPipe类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTagProjection

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private RelationProjection getTagProjection() {
    Relation traitRelation = new TagRelation();
    RelationProjection tagProjection = new RelationProjection("tags", Collections.singleton("name"),
            traitRelation, Projection.Cardinality.MULTIPLE);
    tagProjection.addPipe(new TransformFunctionPipe<>(
            new PipeFunction<Collection<ProjectionResult>, Collection<ProjectionResult>>() {
                @Override
                public Collection<ProjectionResult> compute(Collection<ProjectionResult> results) {
                    for (ProjectionResult result : results) {
                        for (Map<String, Object> properties : result.getPropertyMaps()) {
                            properties.put("href", String.format("v1/entities/%s/tags/%s",
                                    result.getStartingVertex().getProperty("id"), properties.get("name")));
                        }
                    }
                    return results;
                }
            }));
    return tagProjection;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:20,代码来源:EntityResourceDefinition.java

示例2: getDefaultRelationProjection

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private RelationProjection getDefaultRelationProjection() {
    Relation genericRelation = new GenericRelation(this);
    RelationProjection relationProjection = new RelationProjection(
            "relations",
            Arrays.asList("type", "id", "name"),
            genericRelation, Projection.Cardinality.MULTIPLE);

    relationProjection.addPipe(new TransformFunctionPipe<>(
            new PipeFunction<Collection<ProjectionResult>, Collection<ProjectionResult>>() {
                @Override
                public Collection<ProjectionResult> compute(Collection<ProjectionResult> results) {
                    for (ProjectionResult result : results) {
                        for (Map<String, Object> properties : result.getPropertyMaps()) {
                            properties.put("href", String.format("v1/entities/%s", properties.get("id")));
                        }
                    }
                    return results;
                }
            }));
    return relationProjection;
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:22,代码来源:EntityResourceDefinition.java

示例3: getHierarchyProjection

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getHierarchyProjection() {
    final String projectionName = "hierarchy";
    return new Projection(projectionName, Projection.Cardinality.SINGLE,
            new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
                @Override
                public Collection<ProjectionResult> compute(VertexWrapper start) {
                    Map<String, Object> map = new TreeMap<>(new ResourceComparator());

                    TermPath termPath = new TermPath(start.getVertex().<String>getProperty(
                            Constants.ENTITY_TYPE_PROPERTY_KEY));

                    map.put("path", termPath.getPath());
                    map.put("short_name", termPath.getShortName());
                    map.put("taxonomy", termPath.getTaxonomyName());

                    return Collections.singleton(new ProjectionResult(projectionName, start,
                            Collections.singleton(map)));
                }
            }));

}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:22,代码来源:TermResourceDefinition.java

示例4: getTermProjection

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getTermProjection() {
    return new Projection("term", Projection.Cardinality.SINGLE,
            new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
                @Override
                public Collection<ProjectionResult> compute(VertexWrapper start) {
                    Map<String, Object> map = new TreeMap<>(new ResourceComparator());

                    StringBuilder sb = new StringBuilder();
                    sb.append("v1/taxonomies/");

                    String fullyQualifiedName = start.getVertex().getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
                    String[] paths = fullyQualifiedName.split("\\.");
                    // first path segment is the taxonomy
                    sb.append(paths[0]);

                    for (int i = 1; i < paths.length; ++i) {
                        String path = paths[i];
                        if (path != null && !path.isEmpty()) {
                            sb.append("/terms/");
                            sb.append(path);
                        }
                    }

                    map.put("href", sb.toString());
                    return Collections.singleton(new ProjectionResult("term", start,
                            Collections.singleton(map)));
                }
            }));
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:30,代码来源:EntityTagResourceDefinition.java

示例5: getSubTermProjection

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getSubTermProjection() {
    //todo: combine with other term projections
    final String termsProjectionName = "terms";
    return new Projection(termsProjectionName, Projection.Cardinality.SINGLE,
            new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
                @Override
                public Collection<ProjectionResult> compute(VertexWrapper start) {
                    Map<String, Object> map = new TreeMap<>(new ResourceComparator());

                    StringBuilder sb = new StringBuilder();
                    sb.append("v1/taxonomies/");

                    TermPath termPath = new TermPath(start.getVertex().<String>getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY));
                    String[] paths = termPath.getPathSegments();
                    sb.append(termPath.getTaxonomyName());

                    for (String path : paths) {
                        //todo: shouldn't need to check for null or empty after TermPath addition
                        if (path != null && !path.isEmpty()) {
                            sb.append("/terms/");
                            sb.append(path);
                        }
                    }
                    sb.append("/terms");

                    map.put("href", sb.toString());
                    return Collections.singleton(new ProjectionResult(termsProjectionName, start,
                            Collections.singleton(map)));
                }
            }));
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:32,代码来源:TermResourceDefinition.java

示例6: getTermsProjection

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
private Projection getTermsProjection() {
    final String termsProjectionName = "terms";
    return new Projection(termsProjectionName, Projection.Cardinality.SINGLE,
            new TransformFunctionPipe<>(new PipeFunction<VertexWrapper, Collection<ProjectionResult>>() {
                private String baseHref = "v1/taxonomies/";
                @Override
                public Collection<ProjectionResult> compute(VertexWrapper v) {
                    Map<String, Object> map = new HashMap<>();
                    map.put("href", baseHref + v.getProperty("name") + "/terms");
                    return Collections.singleton(new ProjectionResult(termsProjectionName, v,
                            Collections.singleton(map)));
                }
            }));
}
 
开发者ID:apache,项目名称:incubator-atlas,代码行数:15,代码来源:TaxonomyResourceDefinition.java

示例7: EnricherPipeline

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public EnricherPipeline(EnricherConfig... configs) {
	super();
	
	// Create Graph objects from individual statements.
	GroupByPipe<Statement, URI, Statement> groupByPipe = new GroupByPipe<Statement, URI, Statement>(
		new StatementKeyFunction(), 
		new StatementValueFunction());
	Pipeline<Statement, Graph> groupingPipeline = new Pipeline<Statement, Graph>();
	groupingPipeline.addPipe(groupByPipe);
	groupingPipeline.addPipe(new SideEffectCapPipe<Statement, Map<URI, List<Statement>>>(groupByPipe));
	groupingPipeline.addPipe(new ScatterPipe<Map<URI, List<Statement>>, Entry<URI, List<Statement>>>());
	groupingPipeline.addPipe(new TransformFunctionPipe<Entry<URI, List<Statement>>, NamedGraph>(new BuildNamedGraphPipeFunction()));
	this.addPipe(groupingPipeline);
	
	List<Pipe> enrichers = new ArrayList<Pipe>();
	for (EnricherConfig config : configs) {
		enrichers.add(EnricherFactory.getInstance(config));
	}
	
	// Send incoming data through all enricher instances.
	CopySplitPipe<NamedGraph> enricherPipe = new CopySplitPipe<NamedGraph>(enrichers);
	FairMergePipe<List<Statement>> mergerPipe = new FairMergePipe<List<Statement>>(enricherPipe.getPipes());

	this.addPipe(enricherPipe);
	this.addPipe(mergerPipe);
	this.addPipe(new ScatterPipe<List<Statement>, Statement>());
}
 
开发者ID:erfgoed-en-locatie,项目名称:artsholland-platform,代码行数:29,代码来源:EnricherPipeline.java

示例8: transform

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
public <T> PipesPipeline<S, T> transform(final PipeFunction<E, T> function) {
    return this.add(new TransformFunctionPipe(FluentUtility.prepareFunction(this.asMap, function)));
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:4,代码来源:PipesPipeline.java

示例9: transform

import com.tinkerpop.pipes.transform.TransformFunctionPipe; //导入依赖的package包/类
/**
 * Add a TransformFunctionPipe to the end of the Pipeline.
 * Given an input, the provided function is computed on the input and the output of that function is emitted.
 *
 * @param function the transformation function of the pipe
 * @return the extended Pipeline
 */
public <T> GremlinPipeline<S, T> transform(final PipeFunction<E, T> function) {
    return this.add(new TransformFunctionPipe(FluentUtility.prepareFunction(this.asMap, function)));
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:11,代码来源:GremlinPipeline.java


注:本文中的com.tinkerpop.pipes.transform.TransformFunctionPipe类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。