From ad1637ab146ca7d357a08a60d282b6e8a75e9154 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 18 Feb 2021 09:42:51 +0100 Subject: [PATCH] renamed variable --- .../contexts/entities/ContextManagement.java | 4 +- .../instances/base/ElementManagement.java | 38 +++++++------- .../entities/EntityElementManagement.java | 12 ++--- .../relations/RelationElementManagement.java | 12 ++--- .../model/entities/EntityManagement.java | 50 +++++++++---------- .../model/entities/ResourceManagement.java | 5 +- .../model/relations/RelationManagement.java | 26 +++++----- .../EntityTypeDefinitionManagement.java | 24 ++++----- .../PropertyTypeDefinitionManagement.java | 16 +++--- .../ConsistsOfTypeDefinitionManagement.java | 4 +- .../IsRelatedToTypeDefinitionManagement.java | 4 +- .../RelationTypeDefinitionManagement.java | 16 +++--- 12 files changed, 106 insertions(+), 105 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java index 515298f..e8fac87 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java @@ -55,7 +55,7 @@ public class ContextManagement extends EntityElementManagement { 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 { public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException { ObjectMapper objectMapper = new ObjectMapper(); ArrayNode arrayNode = objectMapper.createArrayNode(); - Iterable iterable = oDatabaseDocument.browseClass(elementType, polymorphic); + Iterable iterable = oDatabaseDocument.browseClass(typeName, polymorphic); for(ODocument vertex : iterable) { ContextManagement contextManagement = new ContextManagement(); contextManagement.setElement((OVertex) vertex); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index 1f178a3..20863f4 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -88,7 +88,7 @@ public abstract class ElementManagement { 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 { 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 { } 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 { } public String getElementType() { - return elementType; + return typeName; } protected void checkJsonNode() throws ResourceRegistryException { @@ -226,8 +226,8 @@ public abstract class ElementManagement { 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 { 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 { 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 { } 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 { } 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 { 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 { 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 { 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 { public Set 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 { Set 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) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java index 2cce5c9..0a1ce6b 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/EntityElementManagement.java @@ -111,24 +111,24 @@ public abstract class EntityElementManagement 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 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()); } } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java index 440411b..f2c77d6 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/RelationElementManagement.java @@ -136,7 +136,7 @@ public abstract class RelationElementManagement {}", 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 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 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 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 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 extends EntityElementMa Map 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 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 extends EntityElementMa public Map 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 extends EntityElementMa Map 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 extends EntityElementMa ObjectMapper objectMapper = new ObjectMapper(); ArrayNode arrayNode = objectMapper.createArrayNode(); - Iterable iterable = oDatabaseDocument.browseClass(elementType, polymorphic); + Iterable 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 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 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 extends EntityElementMa if(!polymorphic) { selectStringBuilder.append(" WHERE @class='"); - selectStringBuilder.append(elementType); + selectStringBuilder.append(typeName); selectStringBuilder.append("'"); } @@ -742,7 +742,7 @@ public abstract class EntityManagement extends EntityElementMa throw new ResourceRegistryException(error); } - if(oClass.isSubClassOf(elementType)) { + if(oClass.isSubClassOf(typeName)) { continue; } @@ -804,7 +804,7 @@ public abstract class EntityManagement 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 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); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java index feebfea..f52e5b7 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/ResourceManagement.java @@ -322,8 +322,9 @@ public class ResourceManagement extends EntityManagement { */ 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 { 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 "); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java index 2083a36..17709b0 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java @@ -145,8 +145,8 @@ public abstract class RelationManagement 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 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 edges = oDatabaseDocument.browseClass(elementType, polymorphic); + Iterable edges = oDatabaseDocument.browseClass(typeName, polymorphic); Collection collection = serializeEdges(edges, false); return serializeJsonNodeCollectionAsString(collection); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java index 139eb2b..8406f63 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java @@ -36,7 +36,7 @@ public abstract class EntityTypeDefinitionManagement exten protected EntityTypeDefinitionManagement(Class clz) { super(AccessType.ENTITY_TYPE); - this.elementType = TypeMapper.getType(clz); + this.typeName = TypeMapper.getType(clz); } @Override @@ -72,13 +72,13 @@ public abstract class EntityTypeDefinitionManagement 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 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 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 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 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 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()); } } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java index 996c783..d133076 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java @@ -37,7 +37,7 @@ public class PropertyTypeDefinitionManagement extends ElementManagement()); 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 clz) { super(AccessType.RELATION_TYPE, ResourceType.class, clz); - this.elementType = RelationType.NAME; + this.typeName = RelationType.NAME; } public RelationTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument, Class clz) throws ResourceRegistryException { @@ -89,7 +89,7 @@ public abstract class RelationTypeDefinitionManagement {}", 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()); 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