public Vertex getVertex(final Object id) { if (null == id) throw ExceptionFactory.vertexIdCanNotBeNull(); String idString = id.toString(); return this.vertices.get(idString); }
public String getVertexId(Direction direction) throws IllegalArgumentException { switch (direction) { case IN: return destinationId; case OUT: return sourceId; case BOTH: default: throw ExceptionFactory.bothIsNotSupported(); } }
public Edge getEdge(final Object id) { if (null == id) throw ExceptionFactory.edgeIdCanNotBeNull(); String idString = id.toString(); return this.edges.get(idString); }
/** * Determines whether the property key/value for the specified element can be legally set. * This is typically used as a pre-condition check prior to setting a property. * * @param element the element for the property to be set * @param key the key of the property * @param value the value of the property * @throws IllegalArgumentException whether the triple is legal and if not, a clear reason message is provided */ public static final void validateProperty(final Element element, final String key, final Object value) throws IllegalArgumentException { if (null == value) throw ExceptionFactory.propertyValueCanNotBeNull(); if (null == key) throw ExceptionFactory.propertyKeyCanNotBeNull(); if (key.equals(StringFactory.ID)) throw ExceptionFactory.propertyKeyIdIsReserved(); if (element instanceof Edge && key.equals(StringFactory.LABEL)) throw ExceptionFactory.propertyKeyLabelIsReservedForEdges(); if (key.isEmpty()) throw ExceptionFactory.propertyKeyCanNotBeEmpty(); }
/** * Ensure that the given key/value don't conflict with * Blueprints reserved words. * @param key * @param value */ public static void validateProperty(String key, Object value) { nullCheckProperty(key, value); if (key.equals(StringFactory.ID)) { throw ExceptionFactory.propertyKeyIdIsReserved(); } else if (key.equals(StringFactory.LABEL)) { throw ExceptionFactory.propertyKeyLabelIsReservedForEdges(); } else if (value == null) { throw ExceptionFactory.propertyValueCanNotBeNull(); } }
public void setProperty(final String key, final Object value) { if (key.isEmpty()) throw ExceptionFactory.propertyKeyCanNotBeEmpty(); if (key.equals(StringFactory.ID)) throw ExceptionFactory.propertyKeyIdIsReserved(); if (key.equals(StringFactory.LABEL)) throw ExceptionFactory.propertyKeyLabelIsReservedForEdges(); final Map<String, Object> properties = this.getPropertyMapClone(); properties.put(key, value); this.graph.getRawGraph().setRelationshipProperties(this.id, properties); }
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); Value outVertexValue = ((SailVertex) outVertex).getRawVertex(); Value inVertexValue = ((SailVertex) inVertex).getRawVertex(); if (!(outVertexValue instanceof Resource)) { throw new IllegalArgumentException(outVertex.toString() + " is not a legal URI or blank node"); } try { URI labelURI = new URIImpl(this.expandPrefix(label)); Statement statement = new StatementImpl((Resource) outVertexValue, labelURI, inVertexValue); SailHelper.addStatement(statement, this.sailConnection.get()); return new SailEdge(statement, this); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
public <T extends Element> Set<String> getIndexedKeys(final Class<T> elementClass) { if (elementClass == null) throw ExceptionFactory.classForElementCannotBeNull(); if (Vertex.class.isAssignableFrom(elementClass)) { return this.vertexKeyIndex.getIndexedKeys(); } else if (Edge.class.isAssignableFrom(elementClass)) { return this.edgeKeyIndex.getIndexedKeys(); } else { throw ExceptionFactory.classIsNotIndexable(elementClass); } }
@Override public <T extends Element> void dropKeyIndex(String key, Class<T> elementClass) { if (elementClass == null) { throw ExceptionFactory.classForElementCannotBeNull(); } throw new UnsupportedOperationException(); }
public <T extends Element> void createKeyIndex(String key, Class<T> elementClass, final Parameter... indexParameters) { if (elementClass == null) { throw ExceptionFactory.classForElementCannotBeNull(); } else if (!Vertex.class.isAssignableFrom(elementClass) && !Edge.class.isAssignableFrom(elementClass)) { throw ExceptionFactory.classIsNotIndexable(elementClass); com.sparsity.sparksee.gdb.Attribute adata = rawGraph.getAttribute(attr); if (adata.getKind() != AttributeKind.Basic) { throw ExceptionFactory.indexAlreadyExists(label + " " + key);
public <T extends Element> Index<T> getIndex(final String indexName, final Class<T> indexClass) { Index index = this.indices.get(indexName); if (null == index) return null; if (!indexClass.isAssignableFrom(index.getIndexClass())) throw ExceptionFactory.indexDoesNotSupportClass(indexName, indexClass); else return index; }
public void removeVertex(final Vertex vertex) { Value vertexValue = ((SailVertex) vertex).getRawVertex(); try { if (vertexValue instanceof Resource) { this.sailConnection.get().removeStatements((Resource) vertexValue, null, null); } this.sailConnection.get().removeStatements(null, null, vertexValue); } catch (SailException e) { throw ExceptionFactory.vertexWithIdDoesNotExist(vertex.getId()); } }
@SuppressWarnings("rawtypes") @Override public <T extends Element> Index<T> createIndex(String indexName, Class<T> indexClass, Parameter... indexParameters) { if (indexClass == null) { throw ExceptionFactory.classForElementCannotBeNull(); } else if (globals.getConfig().getIndexableGraphDisabled()) { throw new UnsupportedOperationException("IndexableGraph is disabled via the configuration"); } for (Index<?> index : globals.getIndexMetadataWrapper().getIndices()) { if (index.getIndexName().equals(indexName)) { throw ExceptionFactory.indexAlreadyExists(indexName); } } return globals.getIndexMetadataWrapper().createIndex(indexName, indexClass); }
public void setProperty(final String key, final Object value) { if (key.isEmpty()) throw ExceptionFactory.elementKeyCanNotBeEmpty(); if (key.equals(StringFactory.ID)) throw ExceptionFactory.propertyKeyIdIsReserved(); if (key.equals(StringFactory.LABEL)) throw ExceptionFactory.propertyKeyLabelIsReservedForEdges(); final Map<String, Object> properties = this.getPropertyMapClone(); properties.put(key, value); this.graph.getRawGraph().setRelationshipProperties(this.id, properties); }
public <T extends Element> Index<T> createIndex(final String indexName, final Class<T> indexClass, final Parameter... indexParameters) { if (this.indices.containsKey(indexName)) throw ExceptionFactory.indexAlreadyExists(indexName); final TinkerIndex index = new TinkerIndex(indexName, indexClass); this.indices.put(index.getIndexName(), index); return index; }
public Vertex addVertex(final Object id, final Object... properties) { if (id == null) throw ExceptionFactory.vertexIdCanNotBeNull(); if (retrieveFromCache(id) != null) throw ExceptionFactory.vertexWithIdAlreadyExists(id); nextElement(); Vertex v = baseGraph.addVertex(id); if (vertexIdKey != null) { v.setProperty(vertexIdKey, id); } cache.set(v, id); final BatchVertex newVertex = new BatchVertex(id); setProperties(newVertex, properties); return newVertex; }
public void setProperty(final String key, final Object value) { if (key.isEmpty()) throw ExceptionFactory.propertyKeyCanNotBeEmpty(); if (key.equals(StringFactory.ID)) throw ExceptionFactory.propertyKeyIdIsReserved(); final Map<String, Object> properties = this.getPropertyMapClone(); properties.put(key, value); this.graph.getRawGraph().setNodeProperties(this.id, properties); }
public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) { if (label == null) throw ExceptionFactory.edgeLabelCanNotBeNull(); String idString = null; Edge edge; if (null != id) { idString = id.toString(); edge = this.edges.get(idString); if (null != edge) { throw ExceptionFactory.edgeWithIdAlreadyExist(id); } } else { boolean done = false; while (!done) { idString = this.getNextId(); edge = this.edges.get(idString); if (null == edge) done = true; } } edge = new TinkerEdge(idString, outVertex, inVertex, label, this); this.edges.put(edge.getId().toString(), edge); final TinkerVertex out = (TinkerVertex) outVertex; final TinkerVertex in = (TinkerVertex) inVertex; out.addOutEdge(label, edge); in.addInEdge(label, edge); return edge; }
public void setProperty(final String key, final Object value) { if (key.isEmpty()) throw ExceptionFactory.elementKeyCanNotBeEmpty(); if (key.equals(StringFactory.ID)) throw ExceptionFactory.propertyKeyIdIsReserved(); final Map<String, Object> properties = this.getPropertyMapClone(); properties.put(key, value); this.graph.getRawGraph().setNodeProperties(this.id, properties); }
/** * (Blueprints Extension) Validates an Element property. * * @param element Element instance * @param key Property name * @param value property value * @throws IllegalArgumentException */ public final void validateProperty(final Element element, final String key, final Object value) throws IllegalArgumentException { if (settings.isStandardElementConstraints() && null == value) throw ExceptionFactory.propertyValueCanNotBeNull(); if (null == key) throw ExceptionFactory.propertyKeyCanNotBeNull(); if (settings.isStandardElementConstraints() && key.equals(StringFactory.ID)) throw ExceptionFactory.propertyKeyIdIsReserved(); if (element instanceof Edge && key.equals(StringFactory.LABEL)) throw ExceptionFactory.propertyKeyLabelIsReservedForEdges(); if (key.isEmpty()) throw ExceptionFactory.propertyKeyCanNotBeEmpty(); }