use of org.structr.core.property.TypeProperty in project structr by structr.
the class GraphObject method setProperties.
/**
* Sets the given properties.
*
* @param securityContext
* @param properties
* @throws FrameworkException
*/
default void setProperties(final SecurityContext securityContext, final PropertyMap properties) throws FrameworkException {
final CreationContainer container = new CreationContainer(this);
boolean atLeastOnePropertyChanged = false;
for (final Entry<PropertyKey, Object> attr : properties.entrySet()) {
final PropertyKey key = attr.getKey();
final Object value = attr.getValue();
if (key.indexable(value)) {
final Object oldValue = getProperty(key);
if (!value.equals(oldValue)) {
atLeastOnePropertyChanged = true;
// bulk set possible, store in container
key.setProperty(securityContext, container, value);
if (isNode()) {
if (!key.isUnvalidated()) {
TransactionCommand.nodeModified(securityContext.getCachedUser(), (AbstractNode) this, key, getProperty(key), value);
}
if (key instanceof TypeProperty) {
if (this instanceof NodeInterface) {
final Class type = StructrApp.getConfiguration().getNodeEntityClass((String) value);
TypeProperty.updateLabels(StructrApp.getInstance().getDatabaseService(), (NodeInterface) this, type, true);
}
}
} else if (isRelationship()) {
if (!key.isUnvalidated()) {
TransactionCommand.relationshipModified(securityContext.getCachedUser(), (AbstractRelationship) this, key, getProperty(key), value);
}
if (key instanceof TypeProperty) {
if (this instanceof NodeInterface) {
final Class type = StructrApp.getConfiguration().getNodeEntityClass((String) value);
TypeProperty.updateLabels(StructrApp.getInstance().getDatabaseService(), (NodeInterface) this, type, true);
}
}
}
}
} else {
// bulk set NOT possible, set on entity
if (key.isSystemInternal()) {
unlockSystemPropertiesOnce();
}
setProperty(key, value);
}
}
if (atLeastOnePropertyChanged) {
// set primitive values directly for better performance
getPropertyContainer().setProperties(container.getData());
}
}
Aggregations