use of org.structr.api.UnknownDatabaseException in project structr by structr.
the class GraphObject method setPropertiesInternal.
/**
* Sets the given properties.
*
* @param securityContext
* @param properties
* @param isCreation
*/
default void setPropertiesInternal(final SecurityContext securityContext, final PropertyMap properties, final boolean isCreation) 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 (value != null && key.isPropertyTypeIndexable() && key.relatedType() == null) {
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, oldValue, 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, oldValue, 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, isCreation);
}
}
if (atLeastOnePropertyChanged) {
try {
// set primitive values directly for better performance
getPropertyContainer().setProperties(container.getData());
} catch (UnknownClientException | UnknownDatabaseException e) {
final Logger logger = LoggerFactory.getLogger(GraphObject.class);
logger.warn("Unable to set properties of {} with UUID {}: {}", getType(), getUuid(), e.getMessage());
logger.warn("Properties: {}", container.getData());
}
}
}
Aggregations