protected String checkFieldName(final String iFieldName) { final Character c = OSchemaShared.checkFieldNameIfValid(iFieldName); if (c != null) throw new IllegalArgumentException("Invalid field name '" + iFieldName + "'. Character '" + c + "' is invalid"); return iFieldName; }
public OClass getClass(final String iClassName) { if (iClassName == null) return null; return delegate.getClass(iClassName); }
public OClass getClassByClusterId(int clusterId) { acquireSchemaReadLock(); try { return clustersToClasses.get(clusterId); } finally { releaseSchemaReadLock(); } }
public void removeBlobCluster(ODatabaseDocumentInternal database, String clusterName) { acquireSchemaWriteLock(database); try { int clusterId = getClusterId(database, clusterName); blobClusters.remove(clusterId); } finally { releaseSchemaWriteLock(database); } }
public int addBlobCluster(ODatabaseDocumentInternal database, int clusterId) { acquireSchemaWriteLock(database); try { checkClusterCanBeAdded(clusterId, null); blobClusters.add(clusterId); } finally { releaseSchemaWriteLock(database); } return clusterId; }
@Override public void validate(IValidatable<String> validatable) { String value = validatable.getValue(); if(Strings.isEmpty(value)) { validatable.error(new ValidationError(this, "empty")); } else { Character ch = null; if(checkClassNameValidity) ch = OSchemaShared.checkClassNameIfValid(value); if(ch==null && checkFieldNameValidity) ch = OSchemaShared.checkFieldNameIfValid(value); if(ch!=null) { ValidationError error = new ValidationError(this, "invalidchar"); error.setVariable("char", ch); validatable.error(error); } } }
/** * Register mapping {@link com.orientechnologies.orient.core.record.impl.ODocument} * field name to it s data type {@link OType} * * @param name {@link ODocument} class name. * @param type {@link DocumentFieldType} field data type. */ private void registerDocumentField(String name, DocumentFieldType type) { if (OSchemaShared.checkClassNameIfValid(name) != null) { throw new IllegalArgumentException("'" + name + "' is an invalid field name for a OrientDB document. '" + OSchemaShared.checkClassNameIfValid(name) + "' is not a valid character."); } if (documentFields.containsKey(name) && (documentFields.get(name) != type)) throw new IllegalStateException("The field '" + name + "' is already " + "registered with a different type."); documentFields.put(name, type); }
OGlobalPropertyImpl prop = new OGlobalPropertyImpl(); prop.fromDocument(oDocument); ensurePropertiesSize(prop.getId()); properties.set(prop.getId(), prop); propertiesByNameType.put(prop.getName() + "|" + prop.getType().name(), prop); cls.fromStream(c); } else { cls = createClassInstance(c); cls.fromStream(); newClasses.put(cls.getShortName().toLowerCase(Locale.ENGLISH), cls); addClusterClassMap(cls); ODatabaseDocumentInternal database = ODatabaseRecordThreadLocal.instance().get(); if (database.getStorage().getUnderlying() instanceof OAbstractPaginatedStorage) saveInternal(database);
public OClass getOrCreateClass(final String iClassName, final OClass iSuperClass) { if (iClassName == null) return null; OClass cls = delegate.getClass(iClassName.toLowerCase(Locale.ENGLISH)); if (cls != null) return cls; cls = delegate.getOrCreateClass(database, iClassName, iSuperClass); return cls; }
void changeClassName(ODatabaseDocumentInternal database, final String oldName, final String newName, final OClass cls) { if (oldName != null && oldName.equalsIgnoreCase(newName)) throw new IllegalArgumentException("Class '" + oldName + "' cannot be renamed with the same name"); acquireSchemaWriteLock(database); try { checkEmbedded(); if (newName != null && classes.containsKey(newName.toLowerCase(Locale.ENGLISH))) throw new IllegalArgumentException("Class '" + newName + "' is already present in schema"); if (oldName != null) classes.remove(oldName.toLowerCase(Locale.ENGLISH)); if (newName != null) classes.put(newName.toLowerCase(Locale.ENGLISH), cls); } finally { releaseSchemaWriteLock(database); } }
protected void setShortNameInternal(ODatabaseDocumentInternal database, final String iShortName) { database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { checkEmbedded(); String oldName = null; if (this.shortName != null) oldName = this.shortName; owner.changeClassName(database, oldName, iShortName, this); this.shortName = iShortName; } finally { releaseSchemaWriteLock(); } }
public int addBlobCluster(final int clusterId) { return delegate.addBlobCluster(database, clusterId); }
public void acquireSchemaReadLock() { owner.acquireSchemaReadLock(); }
public void acquireSchemaWriteLock() { owner.acquireSchemaWriteLock(getDatabase()); }
protected OClass addClusterIdInternal(ODatabaseDocumentInternal database, final int clusterId) { acquireSchemaWriteLock(); try { checkEmbedded(); owner.checkClusterCanBeAdded(clusterId, this); for (int currId : clusterIds) if (currId == clusterId) // ALREADY ADDED return this; clusterIds = OArrays.copyOf(clusterIds, clusterIds.length + 1); clusterIds[clusterIds.length - 1] = clusterId; Arrays.sort(clusterIds); addPolymorphicClusterId(clusterId); if (defaultClusterId == NOT_EXISTENT_CLUSTER_ID) defaultClusterId = clusterId; ((OSchemaEmbedded) owner).addClusterForClass(database, clusterId, this); return this; } finally { releaseSchemaWriteLock(); } }
@Override public void validate(IValidatable<String> validatable) { String value = validatable.getValue(); if(Strings.isEmpty(value)) { validatable.error(new ValidationError(this, "empty")); } else { Character ch = null; if(checkClassNameValidity) ch = OSchemaShared.checkClassNameIfValid(value); if(ch==null && checkFieldNameValidity) ch = OSchemaShared.checkFieldNameIfValid(value); if(ch!=null) { ValidationError error = new ValidationError(this, "invalidchar"); error.setVariable("char", ch); validatable.error(error); } } }
public OClass createClass(ODatabaseDocumentInternal database, final String className, int clusters, OClass... superClasses) { final Character wrongCharacter = OSchemaShared.checkClassNameIfValid(className); if (wrongCharacter != null) throw new OSchemaException( "Invalid class name found. Character '" + wrongCharacter + "' cannot be used in class name '" + className + "'"); return doCreateClass(database, className, clusters, superClasses); }
protected void setNameInternal(ODatabaseDocumentInternal database, final String name) { database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { checkEmbedded(); final String oldName = this.name; owner.changeClassName(database, this.name, name, this); this.name = name; renameCluster(oldName, this.name); } finally { releaseSchemaWriteLock(); } }
public OClass getClass(final String iClassName) { if (iClassName == null) return null; acquireSchemaReadLock(); try { return classes.get(iClassName.toLowerCase(Locale.ENGLISH)); } finally { releaseSchemaReadLock(); } }
public OClass createClass(ODatabaseDocumentInternal database, final String className, int[] clusterIds, OClass... superClasses) { final Character wrongCharacter = OSchemaShared.checkClassNameIfValid(className); if (wrongCharacter != null) throw new OSchemaException( "Invalid class name found. Character '" + wrongCharacter + "' cannot be used in class name '" + className + "'"); OClass result; int retry = 0; while (true) try { result = doCreateClass(database, className, clusterIds, retry, superClasses); break; } catch (ClusterIdsAreEmptyException ignore) { classes.remove(className.toLowerCase(Locale.ENGLISH)); clusterIds = createClusters(database, className); retry++; } return result; }