/** * Returns all the Property names as Set of String. out, in and label are not returned as properties even if are part of the * underlying document because are considered internal properties. */ @Override public Set<String> getPropertyKeys() { if (rawElement == null) // LIGHTWEIGHT EDGE return Collections.emptySet(); setCurrentGraphInThreadLocal(); final Set<String> result = new HashSet<String>(); for (String field : getRecord().fieldNames()) if (!field.equals(OrientBaseGraph.CONNECTION_OUT) && !field.equals(OrientBaseGraph.CONNECTION_IN) && ( settings.isUseClassForEdgeLabel() || !field.equals(OrientElement.LABEL_FIELD_NAME))) result.add(field); return result; }
@Override public Map<String, Object> getProperties() { if (this.rawElement == null) return null; final ODocument raw = this.rawElement.getRecord(); if (raw == null) return null; final OrientBaseGraph graph = setCurrentGraphInThreadLocal(); final Map<String, Object> result = new HashMap<String, Object>(); for (String field : raw.fieldNames()) if (!field.equals(OrientBaseGraph.CONNECTION_OUT) && !field.equals(OrientBaseGraph.CONNECTION_IN) && ( settings.isUseClassForEdgeLabel() || !field.equals(OrientElement.LABEL_FIELD_NAME))) result.put(field, raw.field(field)); return result; }
if (settings.isUseClassForEdgeLabel()) {
/** * Returns the Edge's label. By default OrientDB binds the Blueprints Label concept to Edge Class. To disable this feature execute * this at database level <code>alter database custom useClassForEdgeLabel=false * </code> */ @Override public String getLabel() { if (label != null) // LIGHTWEIGHT EDGE return label; else if (rawElement != null) { if (settings != null && settings.isUseClassForEdgeLabel()) { final String clsName = getRecord().getClassName(); if (!OrientEdgeType.CLASS_NAME.equals(clsName)) // RETURN THE CLASS NAME return OrientBaseGraph.decodeClassName(clsName); } setCurrentGraphInThreadLocal(); final ODocument doc = rawElement.getRecord(); if (doc == null) return null; final String label = doc.field(OrientElement.LABEL_FIELD_NAME); if (label != null) return OrientBaseGraph.decodeClassName(label); } return null; }
/** * (Blueprints Extension) Returns the underlying record if it's a regular edge, otherwise it created a document with no identity * with the edge properties. */ @Override public ODocument getRecord() { if (rawElement == null) { // CREATE AT THE FLY final ODocument tmp = new ODocument(getClassName(label)).setTrackingChanges(false); tmp.field(OrientBaseGraph.CONNECTION_IN, vIn.getIdentity()); tmp.field(OrientBaseGraph.CONNECTION_OUT, vOut.getIdentity()); if (label != null && settings != null && !settings.isUseClassForEdgeLabel()) tmp.field(OrientEdge.LABEL_FIELD_NAME, label); return tmp; } return super.getRecord(); }
protected ODocument createDocument(final String iLabel) { final String className = getClassName(iLabel); final ODocument doc = new ODocument(className); if (iLabel != null && !settings.isUseClassForEdgeLabel()) // SET THE LABEL AS FIELD doc.field(OrientElement.LABEL_FIELD_NAME, iLabel); return doc; }
/** * (Blueprints Extension) Returns the class name based on graph settings. */ public String getClassName(final String iLabel) { if (iLabel != null && (settings == null || settings.isUseClassForEdgeLabel())) // USE THE LABEL AS DOCUMENT CLASS return checkForClassInSchema(iLabel); return OrientEdgeType.CLASS_NAME; }
/** * Returns true if the class are use for Edge labels. */ public boolean isUseClassForEdgeLabel() { return settings.isUseClassForEdgeLabel(); }