protected OGlobalProperty findOrCreateGlobalProperty(final String name, final OType type) { OGlobalProperty global = propertiesByNameType.get(name + "|" + type.name()); if (global == null) { int id = properties.size(); global = new OGlobalPropertyImpl(name, type, id); properties.add(id, global); propertiesByNameType.put(global.getName() + "|" + global.getType().name(), global); } return global; }
hasGlobalProperties = true; for (ODocument oDocument : globalProperties) { OGlobalPropertyImpl prop = new OGlobalPropertyImpl(); prop.fromDocument(oDocument); ensurePropertiesSize(prop.getId()); properties.set(prop.getId(), prop); propertiesByNameType.put(prop.getName() + "|" + prop.getType().name(), prop);
public ODocument toNetworkStream() { rwSpinLock.acquireReadLock(); try { ODocument document = new ODocument(); document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING); try { document.field("schemaVersion", CURRENT_VERSION_NUMBER); Set<ODocument> cc = new HashSet<ODocument>(); for (OClass c : classes.values()) cc.add(((OClassImpl) c).toNetworkStream()); document.field("classes", cc, OType.EMBEDDEDSET); List<ODocument> globalProperties = new ArrayList<ODocument>(); for (OGlobalProperty globalProperty : properties) { if (globalProperty != null) globalProperties.add(((OGlobalPropertyImpl) globalProperty).toDocument()); } document.field("globalProperties", globalProperties, OType.EMBEDDEDLIST); document.field("blobClusters", blobClusters, OType.EMBEDDEDSET); } finally { document.setInternalStatus(ORecordElement.STATUS.LOADED); } return document; } finally { rwSpinLock.releaseReadLock(); } }
/** * Binds POJO to ODocument. */ @Override public ODocument toStream() { rwSpinLock.acquireReadLock(); try { document.setInternalStatus(ORecordElement.STATUS.UNMARSHALLING); try { document.field("schemaVersion", CURRENT_VERSION_NUMBER); Set<ODocument> cc = new HashSet<ODocument>(); for (OClass c : classes.values()) cc.add(((OClassImpl) c).toStream()); document.field("classes", cc, OType.EMBEDDEDSET); List<ODocument> globalProperties = new ArrayList<ODocument>(); for (OGlobalProperty globalProperty : properties) { if (globalProperty != null) globalProperties.add(((OGlobalPropertyImpl) globalProperty).toDocument()); } document.field("globalProperties", globalProperties, OType.EMBEDDEDLIST); document.field("blobClusters", blobClusters, OType.EMBEDDEDSET); } finally { document.setInternalStatus(ORecordElement.STATUS.LOADED); } return document; } finally { rwSpinLock.releaseReadLock(); } }
public OGlobalProperty createGlobalProperty(final String name, final OType type, final Integer id) { OGlobalProperty global; if (id < properties.size() && (global = properties.get(id)) != null) { if (!global.getName().equals(name) || !global.getType().equals(type)) throw new OSchemaException("A property with id " + id + " already exist "); return global; } global = new OGlobalPropertyImpl(name, type, id); ensurePropertiesSize(id); properties.set(id, global); propertiesByNameType.put(global.getName() + "|" + global.getType().name(), global); return global; }