protected void setCustomInternal(final String name, final String value) { acquireSchemaWriteLock(); try { checkEmbedded(); if (customFields == null) customFields = new HashMap<String, String>(); if (value == null || "null".equalsIgnoreCase(value)) customFields.remove(name); else customFields.put(name, value); } finally { releaseSchemaWriteLock(); } }
protected void clearCustomInternal() { acquireSchemaWriteLock(); try { checkEmbedded(); customFields = null; } finally { releaseSchemaWriteLock(); } }
protected void removeSuperClassInternal(final OClass superClass) { acquireSchemaWriteLock(); try { final OClassImpl cls; if (superClass instanceof OClassAbstractDelegate) cls = (OClassImpl) ((OClassAbstractDelegate) superClass).delegate; else cls = (OClassImpl) superClass; if (superClasses.contains(cls)) { if (cls != null) cls.removeBaseClassInternal(this); superClasses.remove(superClass); } } finally { releaseSchemaWriteLock(); } }
public void setDefaultClusterId(final int defaultClusterId) { acquireSchemaWriteLock(); try { checkEmbedded(); this.defaultClusterId = defaultClusterId; } finally { releaseSchemaWriteLock(); } }
protected void setDescriptionInternal(final String iDescription) { acquireSchemaWriteLock(); try { checkEmbedded(); this.description = iDescription; } finally { releaseSchemaWriteLock(); } }
protected OClass removeBaseClassInternal(final OClass baseClass) { acquireSchemaWriteLock(); try { checkEmbedded(); if (subclasses == null) return this; if (subclasses.remove(baseClass)) removePolymorphicClusterIds((OClassImpl) baseClass); return this; } finally { releaseSchemaWriteLock(); } }
protected void setOverSizeInternal(ODatabaseDocumentInternal database, final float overSize) { database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { checkEmbedded(); this.overSize = overSize; } finally { releaseSchemaWriteLock(); } }
protected void dropPropertyInternal(ODatabaseDocumentInternal database, final String iPropertyName) { if (database.getTransaction().isActive()) throw new IllegalStateException("Cannot drop a property inside a transaction"); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_DELETE); acquireSchemaWriteLock(); try { checkEmbedded(); final OProperty prop = properties.remove(iPropertyName); if (prop == null) throw new OSchemaException("Property '" + iPropertyName + "' not found in class " + name + "'"); } finally { releaseSchemaWriteLock(); } }
public void setClusterSelectionInternal(final String clusterSelection) { // AVOID TO CHECK THIS IN LOCK TO AVOID RE-GENERATION OF IMMUTABLE SCHEMAS if (this.clusterSelection.getName().equals(clusterSelection)) // NO CHANGES return; acquireSchemaWriteLock(); try { checkEmbedded(); this.clusterSelection = owner.getClusterSelectionFactory().newInstance(clusterSelection); } finally { releaseSchemaWriteLock(); } }
protected void setStrictModeInternal(final boolean iStrict) { getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { checkEmbedded(); this.strictMode = iStrict; } finally { releaseSchemaWriteLock(); } }
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(); } }
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 setShortName(String shortName) { if (shortName != null) { shortName = shortName.trim(); if (shortName.isEmpty()) shortName = null; } final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String.format("alter class `%s` shortname `%s`", name, shortName); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setShortNameInternal(database, shortName); } else setShortNameInternal(database, shortName); } finally { releaseSchemaWriteLock(); } return this; }
public void clearCustom() { final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String.format("alter class `%s` custom clear", getName()); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); clearCustomInternal(); } else clearCustomInternal(); } finally { releaseSchemaWriteLock(); } }
public OClass setStrictMode(final boolean isStrict) { final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String.format("alter class `%s` strictmode %s", name, isStrict); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setStrictModeInternal(isStrict); } else setStrictModeInternal(isStrict); } finally { releaseSchemaWriteLock(); } return this; }
public OClassImpl setEncryption(final String iValue) { final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String.format("alter class `%s` encryption %s", name, iValue); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setEncryptionInternal(database, iValue); } else setEncryptionInternal(database, iValue); } finally { releaseSchemaWriteLock(); } return this; }
public OClass setAbstract(boolean isAbstract) { final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String.format("alter class `%s` abstract %s", name, isAbstract); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setAbstractInternal(database, isAbstract); } else setAbstractInternal(database, isAbstract); } finally { releaseSchemaWriteLock(); } return this; }
@Override public OClass setClusterSelection(final String value) { final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String.format("alter class `%s` clusterselection '%s'", name, value); OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setClusterSelectionInternal(value); } else setClusterSelectionInternal(value); return this; } finally { releaseSchemaWriteLock(); } }
public OClassImpl setCustom(final String name, final String value) { final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String.format("alter class `%s` custom `%s`=%s", getName(), name, value); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); setCustomInternal(name, value); } else setCustomInternal(name, value); return this; } finally { releaseSchemaWriteLock(); } }
@Override public OClass addSuperClass(final OClass superClass) { final ODatabaseDocumentInternal database = getDatabase(); database.checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE); checkParametersConflict(superClass); acquireSchemaWriteLock(); try { final OStorage storage = database.getStorage(); if (isDistributedCommand(database)) { final String cmd = String .format("alter class `%s` superclass +`%s`", name, superClass != null ? superClass.getName() : null); final OCommandSQL commandSQL = new OCommandSQL(cmd); commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId()); database.command(commandSQL).execute(); addSuperClassInternal(database, superClass); } else addSuperClassInternal(database, superClass); } finally { releaseSchemaWriteLock(); } return this; }