DictionaryConst.NODE_TYPE_STEP_PROPERTY, (String) targetTemplateStepVertex.getProperty( DictionaryConst.PROPERTY_LOGICAL_ID ), targetTemplateStepName + ":" + targetTemplateStepAttr.getAttributeKey(), null ); getMetaverseBuilder().addLink( sourceStepField, DictionaryConst.LINK_INPUTS, stepVertex ); final Vertex derivedField = findFieldVertex( parentTransMeta, stepVertex.getProperty( DictionaryConst.PROPERTY_NAME ).toString(), sourceStepField.getProperty( DictionaryConst.PROPERTY_NAME ).toString() ); if ( derivedField != null ) { getMetaverseBuilder().addLink( sourceStepField, DictionaryConst.LINK_DERIVES, derivedField );
private void updateLists(Vertex container, Map<String, JsonObject> fieldMap) { for (Vertex listElement: container.getVertices(Direction.OUT, HAS_LIST)) { String fieldName = listElement.getProperty(FIELD_KEY); if (fieldMap.containsKey(fieldName) && NUMBER_TYPE.equals(fieldMap.get(fieldName).getString(FIELD_LIST_TYPE_KEY))) { listElement.getPropertyKeys().stream() .filter(k -> k.startsWith(ITEM_PREFIX)) .forEach(k -> updateProperty(k, listElement)); } } }
/** * Return the change uuid. * * @return */ public String getUuid() { return vertex.getProperty("uuid"); }
private static Predicate vertexToPredicate(Vertex vertex) { String label = vertex.getProperty("value"); int arity = vertex.getProperty("arity"); return new Predicate(label, arity); }
@Override public Set<Integer> getNodesFromCommunity(int community) { Set<Integer> nodes = new HashSet<Integer>(); Iterable<Vertex> iter = titanGraph.getVertices(COMMUNITY, community); for (Vertex v : iter) { Integer nodeId = v.getProperty(NODE_ID); nodes.add(nodeId); } return nodes; }
/** * Finds the number of elements contained in the given {@code feature}. * * @param vertex the input {@link Vertex} of the {@code feature} * @param feature the {@link EStructuralFeature} describing the feature to access * * @return the size of the {@code feature} if it is multi-valued, {@code 0} otherwise */ protected Integer getSize(Vertex vertex, EStructuralFeature feature) { Integer size = vertex.getProperty(feature.getName() + SEPARATOR + SIZE_LITERAL); return isNull(size) ? 0 : size; }
@Override public Object getValue(Vertex instance, String key, ModelConnection mc) throws RippleException { Object result = instance.getProperty(key); return null == result ? null : BlueprintsLibrary.toRipple(result); }
@Override public int getCommunity(int nodeCommunity) { final Iterator<Vertex> result = graph.getVertices(NODE_COMMUNITY, nodeCommunity).iterator(); if (!result.hasNext()) throw new IllegalArgumentException("node community not found: " + nodeCommunity); Vertex vertex = result.next(); int community = vertex.getProperty(COMMUNITY); return community; }
@Override public int getCommunityFromNode(int nodeId) { Vertex vertex = titanGraph.getVertices(NODE_ID, nodeId).iterator().next(); return vertex.getProperty(COMMUNITY); }
private Vertex findBinary(String hash, Vertex binaryRoot) { for (Vertex binary : binaryRoot.getVertices(OUT, "HAS_BINARY")) { String foundHash = binary.getProperty(NEW_HASH_KEY); if (foundHash.equals(hash)) { return binary; } } return null; }
private void fixName(Vertex schemaVertex) { String name = schemaVertex.getProperty("name"); if (!isEmpty(name)) { name = name.replaceAll("-", "_"); schemaVertex.setProperty("name", name); } }
private Vertex findAdmin() { Vertex admin = null; Iterator<Vertex> langIt = getMeshRootVertex().getVertices(Direction.OUT, "HAS_USER_ROOT").iterator().next() .getVertices(Direction.OUT, "HAS_USER").iterator(); while (langIt.hasNext()) { Vertex user = langIt.next(); if (user.getProperty("username").equals("admin")) { admin = user; } } return admin; }
private Vertex findEnglish() { Vertex english = null; Iterator<Vertex> langIt = getMeshRootVertex().getVertices(Direction.OUT, "HAS_LANGUAGE_ROOT").iterator().next() .getVertices(Direction.OUT, "HAS_LANGUAGE").iterator(); while (langIt.hasNext()) { Vertex language = langIt.next(); if (language.getProperty("languageTag").equals("en")) { english = language; } } return english; }
private void writeGraphNodes(OutputStream os) throws IOException { //iterate the nodes. for(Vertex vertex : graph.getVertices()) { String id = ""+vertex.getId().hashCode(); String label = vertex.getProperty(vertexLabelProperty); if(StringUtils.isBlank(label)) { label = vertex.toString(); } writeGraphNode(id, label, os); } }
private Vertex getOrFixUserReference(Vertex element, String edge) { Vertex creator; Iterator<Vertex> creatorIterator = element.getVertices(Direction.OUT, edge).iterator(); if (!creatorIterator.hasNext()) { log.error("The element {" + element.getProperty("uuid") + "} has no {" + edge + "}. Using admin instead."); creator = findAdmin(); element.addEdge(edge, creator); } else { creator = creatorIterator.next(); } return creator; }
@Override public Boolean compute(Edge edge) { String type = edge.getVertex(Direction.OUT).getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY); VertexWrapper v = new TermVertexWrapper(edge.getVertex(Direction.IN)); return edge.getLabel().startsWith(type) && v.getPropertyKeys().contains("available_as_tag"); } }));
@Test public void arrayProperties_areMappedToLists() { when(node.getPropertyKeys()).thenReturn(newHashSet("foo", "bar")); when(node.getProperty("foo")).thenReturn(new String[]{"elt1", "elt2"}); when(node.getProperty("bar")).thenReturn(new int[]{1,2}); TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil); Vertex v = tgu.addNode(node); assertThat(v.getProperty("foo"), is((Object)newArrayList("elt1", "elt2"))); assertThat(v.getProperty("bar"), is((Object)newArrayList(1, 2))); }
@Test public void propertiesAreTranslated() { when(node.getPropertyKeys()).thenReturn(newHashSet("foo", "baz")); when(node.getProperty("foo")).thenReturn("bar"); when(node.getProperty("baz")).thenReturn(true); TinkerGraphUtil tgu = new TinkerGraphUtil(curieUtil); Vertex v = tgu.addNode(node); assertThat(v.getProperty("foo"), is((Object)"bar")); assertThat(v.getProperty("baz"), is((Object)true)); }
@Override protected Object getAttribute(PersistentEObject object, EAttribute attribute, int index) { Vertex vertex = backend.getVertex(object.id()); String propertyName = attribute.getName(); if (attribute.isMany()) { checkElementIndex(index, getSize(vertex, attribute), "Invalid get index " + index); propertyName += SEPARATOR + index; } return parseProperty(attribute, vertex.getProperty(propertyName)); }
@Test public void properties_areCopied() { Vertex v1 = graph.addVertex(1L); v1.setProperty("foo", "bar"); Vertex v2 = graph.addVertex(2L); TinkerGraphUtil.copyProperties(v1, v2); assertThat((String)v2.getProperty("foo"), is("bar")); }