renamed variable
This commit is contained in:
parent
dbbdd206d5
commit
ad1637ab14
|
@ -55,7 +55,7 @@ public class ContextManagement extends EntityElementManagement<Context> {
|
|||
private void init() {
|
||||
this.ignoreStartWithKeys.add(Context.PARENT_PROPERTY);
|
||||
this.ignoreStartWithKeys.add(Context.CHILDREN_PROPERTY);
|
||||
this.elementType = Context.NAME;
|
||||
this.typeName = Context.NAME;
|
||||
}
|
||||
|
||||
protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
||||
|
@ -400,7 +400,7 @@ public class ContextManagement extends EntityElementManagement<Context> {
|
|||
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ArrayNode arrayNode = objectMapper.createArrayNode();
|
||||
Iterable<ODocument> iterable = oDatabaseDocument.browseClass(elementType, polymorphic);
|
||||
Iterable<ODocument> iterable = oDatabaseDocument.browseClass(typeName, polymorphic);
|
||||
for(ODocument vertex : iterable) {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setElement((OVertex) vertex);
|
||||
|
|
|
@ -88,7 +88,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
protected UUID uuid;
|
||||
protected JsonNode jsonNode;
|
||||
protected OClass oClass;
|
||||
protected String elementType;
|
||||
protected String typeName;
|
||||
|
||||
protected JsonNode self;
|
||||
protected JsonNode complete;
|
||||
|
@ -183,11 +183,11 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
oClass = ElementManagementUtility.getOClass(element);
|
||||
} else {
|
||||
TypesCache typesCache = TypesCache.getInstance();
|
||||
CachedType cachedType = typesCache.getType(elementType);
|
||||
CachedType cachedType = typesCache.getType(typeName);
|
||||
oClass = cachedType.getOClass();
|
||||
AccessType gotAccessType = cachedType.getAccessType();
|
||||
if(accessType!=gotAccessType) {
|
||||
throw new SchemaException(elementType + " is not a " + accessType.getName());
|
||||
throw new SchemaException(typeName + " is not a " + accessType.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,11 +195,11 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
}
|
||||
|
||||
public void setElementType(String elementType) throws ResourceRegistryException {
|
||||
if(this.elementType == null) {
|
||||
if(this.typeName == null) {
|
||||
if(elementType == null || elementType.compareTo("") == 0) {
|
||||
elementType = accessType.getName();
|
||||
}
|
||||
this.elementType = elementType;
|
||||
this.typeName = elementType;
|
||||
} else {
|
||||
if(elementType.compareTo(elementType) != 0) {
|
||||
throw new ResourceRegistryException(
|
||||
|
@ -213,7 +213,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
}
|
||||
|
||||
public String getElementType() {
|
||||
return elementType;
|
||||
return typeName;
|
||||
}
|
||||
|
||||
protected void checkJsonNode() throws ResourceRegistryException {
|
||||
|
@ -226,8 +226,8 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
checkUUIDMatch();
|
||||
}
|
||||
|
||||
if(this.elementType == null) {
|
||||
this.elementType = getClassProperty(jsonNode);
|
||||
if(this.typeName == null) {
|
||||
this.typeName = getClassProperty(jsonNode);
|
||||
getOClass();
|
||||
} else {
|
||||
checkERMatch();
|
||||
|
@ -237,9 +237,9 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
protected void checkERMatch() throws ResourceRegistryException {
|
||||
if(jsonNode != null) {
|
||||
String type = getClassProperty(jsonNode);
|
||||
if(type != null && type.compareTo(elementType) != 0) {
|
||||
if(type != null && type.compareTo(typeName) != 0) {
|
||||
String error = String.format("Requested type does not match with json representation %s!=%s",
|
||||
elementType, type);
|
||||
typeName, type);
|
||||
logger.trace(error);
|
||||
throw new ResourceRegistryException(error);
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
if(resourceUUID.compareTo(uuid) != 0) {
|
||||
String error = String.format(
|
||||
"UUID provided in header (%s) differs from the one (%s) used to identify the %s instance",
|
||||
resourceUUID.toString(), uuid.toString(), elementType);
|
||||
resourceUUID.toString(), uuid.toString(), typeName);
|
||||
throw new ResourceRegistryException(error);
|
||||
|
||||
}
|
||||
|
@ -345,7 +345,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
} catch(ResourceRegistryException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new ResourceRegistryException("Error Creating " + elementType + " with " + jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + typeName + " with " + jsonNode, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -363,7 +363,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
} catch(ResourceRegistryException e) {
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new ResourceRegistryException("Error Updating " + elementType + " with " + jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Updating " + typeName + " with " + jsonNode, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
this.element = element;
|
||||
this.uuid = HeaderUtility.getHeader(element).getUUID();
|
||||
OClass oClass = getOClass();
|
||||
this.elementType = oClass.getName();
|
||||
this.typeName = oClass.getName();
|
||||
}
|
||||
|
||||
protected abstract NotFoundException getSpecificElementNotFoundException(NotFoundException e);
|
||||
|
@ -421,7 +421,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
if(uuid == null) {
|
||||
throw new NotFoundException("null UUID does not allow to retrieve the Element");
|
||||
}
|
||||
return Utility.getElementByUUID(oDatabaseDocument, elementType == null ? accessType.getName() : elementType, uuid,
|
||||
return Utility.getElementByUUID(oDatabaseDocument, typeName == null ? accessType.getName() : typeName, uuid,
|
||||
elementClass);
|
||||
} catch(NotFoundException e) {
|
||||
throw getSpecificElementNotFoundException(e);
|
||||
|
@ -434,7 +434,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
|
||||
public El retrieveElementFromAnyContext() throws NotFoundException, ResourceRegistryException {
|
||||
try {
|
||||
return Utility.getElementByUUIDAsAdmin(elementType == null ? accessType.getName() : elementType, uuid,
|
||||
return Utility.getElementByUUIDAsAdmin(typeName == null ? accessType.getName() : typeName, uuid,
|
||||
elementClass);
|
||||
} catch(NotFoundException e) {
|
||||
throw getSpecificElementNotFoundException(e);
|
||||
|
@ -689,7 +689,7 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
|
||||
|
||||
public Set<String> getContextsSet() throws NotFoundException, ContextException, ResourceRegistryException {
|
||||
logger.debug("Going to get contexts for {} with UUID", elementType, uuid);
|
||||
logger.debug("Going to get contexts for {} with UUID", typeName, uuid);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
|
@ -698,10 +698,10 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
Set<String> contexts = SecurityContext.getContexts(getElement());
|
||||
return contexts;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to get contexts for {} with UUID {}", elementType, uuid, e);
|
||||
logger.error("Unable to get contexts for {} with UUID {}", typeName, uuid, e);
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to get contexts for {} with UUID {}", elementType, uuid, e);
|
||||
logger.error("Unable to get contexts for {} with UUID {}", typeName, uuid, e);
|
||||
throw new ContextException(e);
|
||||
} finally {
|
||||
if(oDatabaseDocument != null) {
|
||||
|
|
|
@ -111,24 +111,24 @@ public abstract class EntityElementManagement<E extends EntityElement> extends E
|
|||
protected OVertex createVertex() throws EntityAlreadyPresentException, ResourceRegistryException {
|
||||
|
||||
logger.trace("Going to create {} for {} ({}) using {}", OVertex.class.getSimpleName(), accessType.getName(),
|
||||
elementType, jsonNode);
|
||||
typeName, jsonNode);
|
||||
|
||||
try {
|
||||
|
||||
if(oClass.isAbstract()) {
|
||||
String error = String.format(
|
||||
"Trying to create an instance of %s of type %s which is abstract. The operation will be aborted.",
|
||||
accessType.getName(), elementType);
|
||||
accessType.getName(), typeName);
|
||||
throw new ResourceRegistryException(error);
|
||||
}
|
||||
|
||||
OVertex vertexEntity = oDatabaseDocument.newVertex(elementType);
|
||||
OVertex vertexEntity = oDatabaseDocument.newVertex(typeName);
|
||||
|
||||
try {
|
||||
if(uuid != null) {
|
||||
OVertex v = getElement();
|
||||
if(v != null) {
|
||||
String error = String.format("A %s with UUID %s already exist", elementType, uuid.toString());
|
||||
String error = String.format("A %s with UUID %s already exist", typeName, uuid.toString());
|
||||
throw getSpecificERAlreadyPresentException(error);
|
||||
}
|
||||
}
|
||||
|
@ -164,8 +164,8 @@ public abstract class EntityElementManagement<E extends EntityElement> extends E
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.trace("Error while creating {} for {} ({}) using {}", OVertex.class.getSimpleName(),
|
||||
accessType.getName(), elementType, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + elementType + " with " + jsonNode, e.getCause());
|
||||
accessType.getName(), typeName, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + typeName + " with " + jsonNode, e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
|||
|
||||
if(!jsonNode.has(Relation.TARGET_PROPERTY)) {
|
||||
throw new ResourceRegistryException(
|
||||
"Error while creating " + elementType + ". No target definition found");
|
||||
"Error while creating " + typeName + ". No target definition found");
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -144,7 +144,7 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
|||
} catch(SchemaException e) {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
errorMessage.append("A ");
|
||||
errorMessage.append(elementType);
|
||||
errorMessage.append(typeName);
|
||||
errorMessage.append(" can be only created beetween ");
|
||||
errorMessage.append(sourceEntityManagement.getAccessType().getName());
|
||||
errorMessage.append(" and ");
|
||||
|
@ -162,9 +162,9 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
|||
OVertex source = (OVertex) getSourceEntityManagement().getElement();
|
||||
OVertex target = (OVertex) getTargetEntityManagement().getElement();
|
||||
|
||||
logger.trace("Going to create {} beetween {} -> {}", elementType, source.toString(), target.toString());
|
||||
logger.trace("Going to create {} beetween {} -> {}", typeName, source.toString(), target.toString());
|
||||
|
||||
element = oDatabaseDocument.newEdge(source, target, elementType);
|
||||
element = oDatabaseDocument.newEdge(source, target, typeName);
|
||||
|
||||
updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
||||
|
@ -178,7 +178,7 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
|||
@Override
|
||||
protected OEdge reallyUpdate() throws ResourceRegistryException {
|
||||
|
||||
logger.debug("Trying to update {} : {}", elementType, jsonNode);
|
||||
logger.debug("Trying to update {} : {}", typeName, jsonNode);
|
||||
|
||||
OEdge edge = getElement();
|
||||
updateProperties(oClass, edge, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
@ -194,7 +194,7 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
|||
}
|
||||
}
|
||||
|
||||
logger.info("{} {} successfully updated", elementType, jsonNode);
|
||||
logger.info("{} {} successfully updated", typeName, jsonNode);
|
||||
|
||||
return edge;
|
||||
|
||||
|
|
|
@ -162,8 +162,8 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
} catch(NotFoundException e) {
|
||||
try {
|
||||
retrieveElementFromAnyContext();
|
||||
throw getSpecificERAvailableInAnotherContextException(elementType == null ? accessType.getName()
|
||||
: elementType + " with UUID " + uuid + " is available in another "
|
||||
throw getSpecificERAvailableInAnotherContextException(typeName == null ? accessType.getName()
|
||||
: typeName + " with UUID " + uuid + " is available in another "
|
||||
+ Context.class.getSimpleName());
|
||||
} catch(AvailableInAnotherContextException e1) {
|
||||
throw e1;
|
||||
|
@ -232,24 +232,24 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
protected OVertex createVertex() throws EntityAlreadyPresentException, ResourceRegistryException {
|
||||
|
||||
logger.trace("Going to create {} for {} ({}) using {}", OVertex.class.getSimpleName(), accessType.getName(),
|
||||
elementType, jsonNode);
|
||||
typeName, jsonNode);
|
||||
|
||||
try {
|
||||
|
||||
if(oClass.isAbstract()) {
|
||||
String error = String.format(
|
||||
"Trying to create an instance of %s of type %s which is abstract. The operation will be aborted.",
|
||||
accessType.getName(), elementType);
|
||||
accessType.getName(), typeName);
|
||||
throw new ResourceRegistryException(error);
|
||||
}
|
||||
|
||||
OVertex vertexEntity = oDatabaseDocument.newVertex(elementType);
|
||||
OVertex vertexEntity = oDatabaseDocument.newVertex(typeName);
|
||||
|
||||
try {
|
||||
if(uuid != null) {
|
||||
OVertex v = getElement();
|
||||
if(v != null) {
|
||||
String error = String.format("A %s with UUID %s already exist", elementType, uuid.toString());
|
||||
String error = String.format("A %s with UUID %s already exist", typeName, uuid.toString());
|
||||
throw getSpecificERAlreadyPresentException(error);
|
||||
}
|
||||
}
|
||||
|
@ -284,8 +284,8 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.trace("Error while creating {} for {} ({}) using {}", OVertex.class.getSimpleName(),
|
||||
accessType.getName(), elementType, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + elementType + " with " + jsonNode, e.getCause());
|
||||
accessType.getName(), typeName, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + typeName + " with " + jsonNode, e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new ResourceRegistryException(
|
||||
"Error Adding " + elementType + " to " + targetSecurityContext.toString(), e.getCause());
|
||||
"Error Adding " + typeName + " to " + targetSecurityContext.toString(), e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,17 +349,17 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
Map<UUID,JsonNode> affectedInstances = internalAddToContext(targetSecurityContext);
|
||||
|
||||
oDatabaseDocument.commit();
|
||||
logger.info("{} with UUID {} successfully added to Context with UUID {}", elementType, uuid, contextUUID);
|
||||
logger.info("{} with UUID {} successfully added to Context with UUID {}", typeName, uuid, contextUUID);
|
||||
|
||||
return affectedInstances;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to add {} with UUID {} to Context with UUID {} - Reason is {}", elementType, uuid, contextUUID, e.getMessage());
|
||||
logger.error("Unable to add {} with UUID {} to Context with UUID {} - Reason is {}", typeName, uuid, contextUUID, e.getMessage());
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to add {} with UUID {} to Context with UUID {}", elementType, uuid, contextUUID, e);
|
||||
logger.error("Unable to add {} with UUID {} to Context with UUID {}", typeName, uuid, contextUUID, e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new ResourceRegistryException(
|
||||
"Error Removing " + elementType + " from " + targetSecurityContext.toString(), e.getCause());
|
||||
"Error Removing " + typeName + " from " + targetSecurityContext.toString(), e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -425,7 +425,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
|
||||
public Map<UUID,JsonNode> removeFromContext(UUID contextUUID)
|
||||
throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
oDatabaseDocument = ContextUtility.getAdminSecurityContext().getDatabaseDocument(PermissionMode.WRITER);
|
||||
|
@ -436,17 +436,17 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
Map<UUID,JsonNode> affectedInstances = internalRemoveFromContext(targetSecurityContext);
|
||||
|
||||
oDatabaseDocument.commit();
|
||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", elementType, uuid, contextUUID);
|
||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
|
||||
return affectedInstances;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID,
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID,
|
||||
e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
|
@ -468,7 +468,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ArrayNode arrayNode = objectMapper.createArrayNode();
|
||||
|
||||
Iterable<ODocument> iterable = oDatabaseDocument.browseClass(elementType, polymorphic);
|
||||
Iterable<ODocument> iterable = oDatabaseDocument.browseClass(typeName, polymorphic);
|
||||
for(ODocument vertex : iterable) {
|
||||
EntityManagement<?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
|
||||
oDatabaseDocument, (OVertex) vertex);
|
||||
|
@ -622,8 +622,8 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
* if the resulting type is a subclass of the requested type
|
||||
*
|
||||
*/
|
||||
if(oClass.getName().compareTo(elementType)!=0) {
|
||||
if(polymorphic && oClass.isSubClassOf(elementType)) {
|
||||
if(oClass.getName().compareTo(typeName)!=0) {
|
||||
if(polymorphic && oClass.isSubClassOf(typeName)) {
|
||||
// OK
|
||||
} else {
|
||||
// excluding from results
|
||||
|
@ -693,7 +693,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
selectStringBuilder.append("'), ");
|
||||
selectStringBuilder.append(direction.opposite().name().toLowerCase());
|
||||
selectStringBuilder.append("V('");
|
||||
selectStringBuilder.append(elementType);
|
||||
selectStringBuilder.append(typeName);
|
||||
selectStringBuilder.append("') FROM (SELECT FROM ");
|
||||
selectStringBuilder.append(referenceType);
|
||||
boolean first = true;
|
||||
|
@ -715,7 +715,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
|
||||
if(!polymorphic) {
|
||||
selectStringBuilder.append(" WHERE @class='");
|
||||
selectStringBuilder.append(elementType);
|
||||
selectStringBuilder.append(typeName);
|
||||
selectStringBuilder.append("'");
|
||||
}
|
||||
|
||||
|
@ -742,7 +742,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
throw new ResourceRegistryException(error);
|
||||
}
|
||||
|
||||
if(oClass.isSubClassOf(elementType)) {
|
||||
if(oClass.isSubClassOf(typeName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -804,7 +804,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
|
||||
if(direction != ODirection.OUT) {
|
||||
String error = String.format("%s can only goes %s from %s.", relationType,
|
||||
ODirection.OUT.name(), elementType);
|
||||
ODirection.OUT.name(), typeName);
|
||||
throw new InvalidQueryException(error);
|
||||
} else {
|
||||
if(referenceAccessType != AccessType.FACET) {
|
||||
|
@ -820,7 +820,7 @@ public abstract class EntityManagement<E extends Entity> extends EntityElementMa
|
|||
case FACET:
|
||||
if(relationAccessType != AccessType.CONSISTS_OF || direction != ODirection.IN
|
||||
|| referenceAccessType != AccessType.RESOURCE) {
|
||||
String error = String.format("%s can only has %s %s from a %s.", elementType,
|
||||
String error = String.format("%s can only has %s %s from a %s.", typeName,
|
||||
ODirection.IN.name(), ConsistsOf.NAME, Resource.NAME);
|
||||
throw new InvalidQueryException(error);
|
||||
}
|
||||
|
|
|
@ -322,8 +322,9 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
|||
*/
|
||||
read();
|
||||
|
||||
|
||||
ResourceTypeDefinitionManagement resourceTypeDefinitionManagement = new ResourceTypeDefinitionManagement();
|
||||
resourceTypeDefinitionManagement.setName(elementType);
|
||||
resourceTypeDefinitionManagement.setName(typeName);
|
||||
String stringType = resourceTypeDefinitionManagement.read().toString();
|
||||
ResourceType resourceType = null;
|
||||
try {
|
||||
|
@ -382,7 +383,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
|||
stringBuffer.append("To avoid to have an incosistent graph, add to context no follows cannot add a ");
|
||||
stringBuffer.append(Resource.NAME);
|
||||
stringBuffer.append(" (i.e. ");
|
||||
stringBuffer.append(elementType);
|
||||
stringBuffer.append(typeName);
|
||||
stringBuffer.append(" with UUID ");
|
||||
stringBuffer.append(uuid.toString());
|
||||
stringBuffer.append(") without adding at least a ");
|
||||
|
|
|
@ -145,8 +145,8 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
} catch(NotFoundException e) {
|
||||
try {
|
||||
retrieveElementFromAnyContext();
|
||||
throw getSpecificERAvailableInAnotherContextException(elementType == null ? accessType.getName()
|
||||
: elementType + " with UUID " + uuid + " is available in another "
|
||||
throw getSpecificERAvailableInAnotherContextException(typeName == null ? accessType.getName()
|
||||
: typeName + " with UUID " + uuid + " is available in another "
|
||||
+ Context.class.getSimpleName());
|
||||
} catch(AvailableInAnotherContextException e1) {
|
||||
throw e1;
|
||||
|
@ -323,7 +323,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
|
||||
checkPropagationConstraint();
|
||||
|
||||
logger.info("{} successfully created", elementType);
|
||||
logger.info("{} successfully created", typeName);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
@Override
|
||||
protected OEdge reallyUpdate() throws ResourceRegistryException {
|
||||
|
||||
logger.debug("Trying to update {} : {}", elementType, jsonNode);
|
||||
logger.debug("Trying to update {} : {}", typeName, jsonNode);
|
||||
|
||||
OEdge edge = getElement();
|
||||
updateProperties(oClass, edge, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
@ -356,7 +356,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
}
|
||||
}
|
||||
|
||||
logger.info("{} {} successfully updated", elementType, jsonNode);
|
||||
logger.info("{} {} successfully updated", typeName, jsonNode);
|
||||
|
||||
return edge;
|
||||
|
||||
|
@ -451,7 +451,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new ResourceRegistryException(
|
||||
"Error Adding " + elementType + " to " + targetSecurityContext.toString(), e.getCause());
|
||||
"Error Adding " + typeName + " to " + targetSecurityContext.toString(), e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,13 +611,13 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
throw new ResourceRegistryException(
|
||||
"Error Removing " + elementType + " from " + targetSecurityContext.toString(), e.getCause());
|
||||
"Error Removing " + typeName + " from " + targetSecurityContext.toString(), e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
public Map<UUID,JsonNode> removeFromContext(UUID contextUUID)
|
||||
throws NotFoundException, ContextException, ResourceRegistryException {
|
||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
oDatabaseDocument = ContextUtility.getAdminSecurityContext().getDatabaseDocument(PermissionMode.WRITER);
|
||||
|
@ -628,17 +628,17 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
Map<UUID,JsonNode> affectedInstances = internalRemoveFromContext(targetSecurityContext);
|
||||
|
||||
oDatabaseDocument.commit();
|
||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", elementType, uuid, contextUUID);
|
||||
logger.info("{} with UUID {} successfully removed from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
|
||||
return affectedInstances;
|
||||
} catch(ResourceRegistryException e) {
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID);
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
}
|
||||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", elementType, uuid, contextUUID,
|
||||
logger.error("Unable to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID,
|
||||
e);
|
||||
if(oDatabaseDocument != null) {
|
||||
oDatabaseDocument.rollback();
|
||||
|
@ -718,7 +718,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
OEdge edge = (OEdge) d;
|
||||
|
||||
// TODO check because it was using compare
|
||||
if(postFilterPolymorphic && getOClass().isSubClassOf(elementType)) {
|
||||
if(postFilterPolymorphic && getOClass().isSubClassOf(typeName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
|
||||
@Override
|
||||
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
||||
Iterable<ODocument> edges = oDatabaseDocument.browseClass(elementType, polymorphic);
|
||||
Iterable<ODocument> edges = oDatabaseDocument.browseClass(typeName, polymorphic);
|
||||
Collection<JsonNode> collection = serializeEdges(edges, false);
|
||||
return serializeJsonNodeCollectionAsString(collection);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
|
||||
protected EntityTypeDefinitionManagement(Class<E> clz) {
|
||||
super(AccessType.ENTITY_TYPE);
|
||||
this.elementType = TypeMapper.getType(clz);
|
||||
this.typeName = TypeMapper.getType(clz);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -72,13 +72,13 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
|
||||
@Override
|
||||
protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException {
|
||||
logger.debug("Going to create {} for {}", this.elementType, getName());
|
||||
logger.debug("Going to create {} for {}", this.typeName, getName());
|
||||
return createVertex();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected OVertex reallyUpdate() throws NotFoundException, ResourceRegistryException {
|
||||
logger.debug("Going to update {} for {}", this.elementType, getName());
|
||||
logger.debug("Going to update {} for {}", this.typeName, getName());
|
||||
OVertex entityTypeDefinition = getElement();
|
||||
entityTypeDefinition = (OVertex) updateProperties(oClass, entityTypeDefinition, jsonNode,
|
||||
ignoreKeys, ignoreStartWithKeys);
|
||||
|
@ -87,7 +87,7 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
|
||||
@Override
|
||||
protected boolean reallyDelete() throws NotFoundException, ResourceRegistryException {
|
||||
logger.debug("Going to remove {} for {}", this.elementType, getName());
|
||||
logger.debug("Going to remove {} for {}", this.typeName, getName());
|
||||
getElement().delete();
|
||||
return true;
|
||||
}
|
||||
|
@ -120,13 +120,13 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
throw new NotFoundException("null name does not allow to retrieve the Element");
|
||||
}
|
||||
|
||||
String select = "SELECT FROM " + elementType + " WHERE " + EntityType.NAME_PROPERTY + " = \""
|
||||
String select = "SELECT FROM " + typeName + " WHERE " + EntityType.NAME_PROPERTY + " = \""
|
||||
+ getName() + "\"";
|
||||
|
||||
OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>());
|
||||
|
||||
if(resultSet == null || !resultSet.hasNext()) {
|
||||
String error = String.format("No %s with name %s was found", elementType, getName());
|
||||
String error = String.format("No %s with name %s was found", typeName, getName());
|
||||
logger.info(error);
|
||||
throw new NotFoundException(error);
|
||||
}
|
||||
|
@ -134,10 +134,10 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
OResult oResult = resultSet.next();
|
||||
OVertex element = (OVertex) ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
||||
|
||||
logger.trace("{} with id {} is : {}", elementType, getName(), Utility.toJsonString(element, true));
|
||||
logger.trace("{} with id {} is : {}", typeName, getName(), Utility.toJsonString(element, true));
|
||||
|
||||
if(resultSet.hasNext()) {
|
||||
throw new ResourceRegistryException("Found more than one " + elementType + " with name " + getName()
|
||||
throw new ResourceRegistryException("Found more than one " + typeName + " with name " + getName()
|
||||
+ ". This is a fatal error please contact Admnistrator");
|
||||
}
|
||||
|
||||
|
@ -155,11 +155,11 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
protected OVertex createVertex() throws EntityAlreadyPresentException, ResourceRegistryException {
|
||||
|
||||
logger.trace("Going to create {} for {} ({}) using {}", OVertex.class.getSimpleName(), accessType.getName(),
|
||||
elementType, jsonNode);
|
||||
typeName, jsonNode);
|
||||
|
||||
try {
|
||||
|
||||
this.element = oDatabaseDocument.newVertex(elementType);
|
||||
this.element = oDatabaseDocument.newVertex(typeName);
|
||||
|
||||
updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
||||
|
@ -170,8 +170,8 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.trace("Error while creating {} for {} ({}) using {}", OVertex.class.getSimpleName(),
|
||||
accessType.getName(), elementType, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + elementType + " with " + jsonNode, e.getCause());
|
||||
accessType.getName(), typeName, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + typeName + " with " + jsonNode, e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
|
|||
|
||||
public PropertyTypeDefinitionManagement() {
|
||||
super(AccessType.PROPERTY_TYPE);
|
||||
this.elementType = PropertyType.NAME;
|
||||
this.typeName = PropertyType.NAME;
|
||||
}
|
||||
|
||||
public PropertyTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
||||
|
@ -127,13 +127,13 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
|
|||
throw new NotFoundException("null name does not allow to retrieve the Element");
|
||||
}
|
||||
|
||||
String select = "SELECT FROM " + elementType + " WHERE " + PropertyType.NAME_PROPERTY + " = \""
|
||||
String select = "SELECT FROM " + typeName + " WHERE " + PropertyType.NAME_PROPERTY + " = \""
|
||||
+ getName() + "\"";
|
||||
|
||||
OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>());
|
||||
|
||||
if(resultSet == null || !resultSet.hasNext()) {
|
||||
String error = String.format("No %s with name %s was found", elementType, getName());
|
||||
String error = String.format("No %s with name %s was found", typeName, getName());
|
||||
logger.info(error);
|
||||
throw new NotFoundException(error);
|
||||
}
|
||||
|
@ -141,10 +141,10 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
|
|||
OResult oResult = resultSet.next();
|
||||
OElement element = (OElement) ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
||||
|
||||
logger.trace("{} with id {} is : {}", elementType, getName(), Utility.toJsonString(element, true));
|
||||
logger.trace("{} with id {} is : {}", typeName, getName(), Utility.toJsonString(element, true));
|
||||
|
||||
if(resultSet.hasNext()) {
|
||||
throw new ResourceRegistryException("Found more than one " + elementType + " with name " + getName()
|
||||
throw new ResourceRegistryException("Found more than one " + typeName + " with name " + getName()
|
||||
+ ". This is a fatal error please contact Admnistrator");
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
|
|||
|
||||
protected OElement createElement() throws AlreadyPresentException, ResourceRegistryException {
|
||||
try {
|
||||
this.element = new ODocument(elementType);
|
||||
this.element = new ODocument(typeName);
|
||||
|
||||
updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
||||
|
@ -171,8 +171,8 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
|
|||
throw e;
|
||||
} catch(Exception e) {
|
||||
logger.trace("Error while creating {} for {} ({}) using {}", OElement.class.getSimpleName(),
|
||||
accessType.getName(), elementType, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + elementType + " with " + jsonNode, e.getCause());
|
||||
accessType.getName(), typeName, jsonNode, e);
|
||||
throw new ResourceRegistryException("Error Creating " + typeName + " with " + jsonNode, e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,13 +16,13 @@ public class ConsistsOfTypeDefinitionManagement
|
|||
|
||||
public ConsistsOfTypeDefinitionManagement() {
|
||||
super(FacetType.class);
|
||||
this.elementType = ConsistsOfType.NAME;
|
||||
this.typeName = ConsistsOfType.NAME;
|
||||
}
|
||||
|
||||
public ConsistsOfTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument)
|
||||
throws ResourceRegistryException {
|
||||
super(securityContext, oDatabaseDocument, FacetType.class);
|
||||
this.elementType = ConsistsOfType.NAME;
|
||||
this.typeName = ConsistsOfType.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -16,13 +16,13 @@ public class IsRelatedToTypeDefinitionManagement
|
|||
|
||||
public IsRelatedToTypeDefinitionManagement() {
|
||||
super(ResourceType.class);
|
||||
this.elementType = IsRelatedToType.NAME;
|
||||
this.typeName = IsRelatedToType.NAME;
|
||||
}
|
||||
|
||||
public IsRelatedToTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument)
|
||||
throws ResourceRegistryException {
|
||||
super(securityContext, oDatabaseDocument, ResourceType.class);
|
||||
this.elementType = IsRelatedToType.NAME;
|
||||
this.typeName = IsRelatedToType.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,7 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
|||
|
||||
public RelationTypeDefinitionManagement(Class<TT> clz) {
|
||||
super(AccessType.RELATION_TYPE, ResourceType.class, clz);
|
||||
this.elementType = RelationType.NAME;
|
||||
this.typeName = RelationType.NAME;
|
||||
}
|
||||
|
||||
public RelationTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument, Class<TT> clz) throws ResourceRegistryException {
|
||||
|
@ -89,7 +89,7 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
|||
if(targetEntityManagement == null) {
|
||||
if(!jsonNode.has(Relation.TARGET_PROPERTY)) {
|
||||
throw new ResourceRegistryException(
|
||||
"Error while creating " + elementType + ". No target definition found");
|
||||
"Error while creating " + typeName + ". No target definition found");
|
||||
}
|
||||
|
||||
targetEntityManagement = newTargetEntityManagement();
|
||||
|
@ -100,10 +100,10 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
|||
OVertex source = (OVertex) getSourceEntityManagement().getElement();
|
||||
OVertex target = (OVertex) getTargetEntityManagement().getElement();
|
||||
|
||||
logger.trace("Creating {} beetween {} -> {}", elementType, source.toString(),
|
||||
logger.trace("Creating {} beetween {} -> {}", typeName, source.toString(),
|
||||
target.toString());
|
||||
|
||||
element = oDatabaseDocument.newEdge(source, target, elementType);
|
||||
element = oDatabaseDocument.newEdge(source, target, typeName);
|
||||
|
||||
updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
||||
|
@ -155,13 +155,13 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
|||
throw new NotFoundException("null name does not allow to retrieve the Element");
|
||||
}
|
||||
|
||||
String select = "SELECT FROM " + elementType + " WHERE " + RelationType.NAME_PROPERTY + " = \""
|
||||
String select = "SELECT FROM " + typeName + " WHERE " + RelationType.NAME_PROPERTY + " = \""
|
||||
+ getName() + "\"";
|
||||
|
||||
OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>());
|
||||
|
||||
if(resultSet == null || !resultSet.hasNext()) {
|
||||
String error = String.format("No %s with name %s was found", elementType, getName());
|
||||
String error = String.format("No %s with name %s was found", typeName, getName());
|
||||
logger.info(error);
|
||||
throw new NotFoundException(error);
|
||||
}
|
||||
|
@ -169,10 +169,10 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
|||
OResult oResult = resultSet.next();
|
||||
OEdge element = (OEdge) ElementManagementUtility.getElementFromOptional(oResult.getElement());
|
||||
|
||||
logger.trace("{} with id {} is : {}", elementType, getName(), Utility.toJsonString(element, true));
|
||||
logger.trace("{} with id {} is : {}", typeName, getName(), Utility.toJsonString(element, true));
|
||||
|
||||
if(resultSet.hasNext()) {
|
||||
throw new ResourceRegistryException("Found more than one " + elementType + " with name " + getName()
|
||||
throw new ResourceRegistryException("Found more than one " + typeName + " with name " + getName()
|
||||
+ ". This is a fatal error please contact Admnistrator");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue