@Override public Integer getId() { return globalRef.getId(); }
private Tuple<Boolean, String> checkIfPropertyNameMatchSome(OGlobalProperty prop, final String[] iFields) { String fieldName = prop.getName(); boolean matchField = false; for (String f : iFields) { if (fieldName.equals(f)) { matchField = true; break; } } return new Tuple<>(matchField, fieldName); }
public String getName() { acquireSchemaReadLock(); try { return globalRef.getName(); } finally { releaseSchemaReadLock(); } }
public OType getType() { acquireSchemaReadLock(); try { return globalRef.getType(); } finally { releaseSchemaReadLock(); } }
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; }
/** * Returns the first index defined for the property. * * @deprecated Use {@link OClass#getInvolvedIndexes(String...)} instead. */ @Deprecated public OIndex<?> getIndex() { acquireSchemaReadLock(); try { Set<OIndex<?>> indexes = owner.getInvolvedIndexes(globalRef.getName()); if (indexes != null && !indexes.isEmpty()) return indexes.iterator().next(); return null; } finally { releaseSchemaReadLock(); } }
protected void checkForDateFormat(final String iDateAsString) { if (iDateAsString != null) if (globalRef.getType() == OType.DATE) { try { getDatabase().getStorage().getConfiguration().getDateFormatInstance().parse(iDateAsString); } catch (ParseException e) { throw OException .wrapException(new OSchemaException("Invalid date format while formatting date '" + iDateAsString + "'"), e); } } else if (globalRef.getType() == OType.DATETIME) { try { getDatabase().getStorage().getConfiguration().getDateTimeFormatInstance().parse(iDateAsString); } catch (ParseException e) { throw OException .wrapException(new OSchemaException("Invalid datetime format while formatting date '" + iDateAsString + "'"), e); } } }
document.field("name", getName()); document.field("type", getType().id); document.field("globalId", globalRef.getId()); document.field("mandatory", mandatory); document.field("readonly", readonly);
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; }
/** * @deprecated Use {@link OClass#getInvolvedIndexes(String...)} instead. */ @Deprecated public Set<OIndex<?>> getIndexes() { acquireSchemaReadLock(); try { return owner.getInvolvedIndexes(globalRef.getName()); } finally { releaseSchemaReadLock(); } }
document.field("name", getName()); document.field("type", getType().id); document.field("globalId", globalRef.getId()); document.field("mandatory", mandatory); document.field("readonly", readonly);
/** * Change the type. It checks for compatibility between the change of type. * * @param iType */ protected void setTypeInternal(final OType iType) { getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { if (iType == globalRef.getType()) // NO CHANGES return; if (!iType.getCastable().contains(globalRef.getType())) throw new IllegalArgumentException("Cannot change property type from " + globalRef.getType() + " to " + iType); this.globalRef = owner.owner.findOrCreateGlobalProperty(this.globalRef.getName(), iType); } finally { releaseSchemaWriteLock(); } }
public int compareTo(final OProperty o) { acquireSchemaReadLock(); try { return globalRef.getName().compareTo(o.getName()); } finally { releaseSchemaReadLock(); } }
protected void setNameInternal(final String name) { getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); String oldName = this.globalRef.getName(); acquireSchemaWriteLock(); try { checkEmbedded(); owner.renameProperty(oldName, name); this.globalRef = owner.owner.findOrCreateGlobalProperty(name, this.globalRef.getType()); } finally { releaseSchemaWriteLock(); } owner.firePropertyNameMigration(getDatabase(), oldName, name, this.globalRef.getType()); }
/** * @deprecated Use {@link OClass#areIndexed(String...)} instead. */ @Deprecated public boolean isIndexed() { acquireSchemaReadLock(); try { return owner.areIndexed(globalRef.getName()); } finally { releaseSchemaReadLock(); } }
@Override public String[] getFieldNames(ODocument reference, final BytesContainer bytes, boolean deserializeClassName) { // SKIP CLASS NAME final int classNameLen = OVarIntSerializer.readAsInteger(bytes); bytes.skip(classNameLen); final List<String> result = new ArrayList<String>(); String fieldName; while (true) { OGlobalProperty prop = null; final int len = OVarIntSerializer.readAsInteger(bytes); if (len == 0) { // SCAN COMPLETED break; } else if (len > 0) { // PARSE FIELD NAME fieldName = stringFromBytes(bytes.bytes, bytes.offset, len).intern(); result.add(fieldName); // SKIP THE REST bytes.skip(len + OIntegerSerializer.INT_SIZE + 1); } else { // LOAD GLOBAL PROPERTY BY ID final int id = (len * -1) - 1; prop = ODocumentInternal.getGlobalPropertyById(reference, id); result.add(prop.getName()); // SKIP THE REST bytes.skip(OIntegerSerializer.INT_SIZE + (prop.getType() != OType.ANY ? 0 : 1)); } } return result.toArray(new String[result.size()]); }
public String getFullNameQuoted() { acquireSchemaReadLock(); try { return "`" + owner.getName() + "`.`" + globalRef.getName() + "`"; } finally { releaseSchemaReadLock(); } }