Solved rawtypes and Removed some @SuppressWarnings("rawtypes")

This commit is contained in:
Luca Frosini 2021-03-05 15:04:27 +01:00
parent 05a8825635
commit 6b999a54ef
7 changed files with 28 additions and 31 deletions

View File

@ -38,8 +38,7 @@ public abstract class EntityElementManagement<E extends EntityElement, ET extend
* Provide a cache edge-internal-id -> RelationManagement
* this avoid to recreate the relationManagement of already visited edges
*/
@SuppressWarnings("rawtypes")
protected Map<String,RelationElementManagement> relationManagements;
protected Map<String,RelationElementManagement<?,?,?,?>> relationManagements;
protected EntityElementManagement(AccessType accessType) {
super(accessType);
@ -61,16 +60,15 @@ public abstract class EntityElementManagement<E extends EntityElement, ET extend
setWorkingContext(workingContext);
}
@SuppressWarnings("rawtypes")
/*
* It works perfectly in case of any kind of update. In case of use from create
* the cache does not work by using the ID because until commit the edge has a
* fake id starting with - (minus) sign. This not imply any collateral effect
* but a better solution is a desiderata.
*/
protected RelationElementManagement getBaseRelationManagement(OEdge edge) throws ResourceRegistryException {
protected RelationElementManagement<?,?,?,?> getBaseRelationManagement(OEdge edge) throws ResourceRegistryException {
String id = edge.getIdentity().toString();
RelationElementManagement relationManagement = relationManagements.get(id);
RelationElementManagement<?,?,?,?> relationManagement = relationManagements.get(id);
if(relationManagement == null) {
relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge);
relationManagements.put(id, relationManagement);
@ -78,7 +76,7 @@ public abstract class EntityElementManagement<E extends EntityElement, ET extend
return relationManagement;
}
protected void addToRelationManagement(@SuppressWarnings("rawtypes") RelationElementManagement baseRelationManagement)
protected void addToRelationManagement(RelationElementManagement<?,?,?,?> baseRelationManagement)
throws ResourceRegistryException {
OElement elem = baseRelationManagement.getElement();
String id = elem.getIdentity().toString();

View File

@ -205,7 +205,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
return relationManagement;
}
protected void addToRelationManagement(@SuppressWarnings("rawtypes") RelationManagement relationManagement)
public void addToRelationManagement(RelationManagement<?,?> relationManagement)
throws ResourceRegistryException {
OElement elem = relationManagement.getElement();
String id = elem.getIdentity().toString();
@ -534,8 +534,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
if(referenceUUID != null) {
OElement element = ElementManagementUtility.getAnyElementByUUID(oDatabaseDocument, referenceUUID);
if(element instanceof OVertex) {
@SuppressWarnings("unchecked")
EntityManagement<Entity, EntityType> entityManagement = (EntityManagement<Entity, EntityType>) ElementManagementUtility.getEntityManagement(getWorkingContext(),
EntityManagement<?, ?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
oDatabaseDocument, (OVertex) element);
String elementType = entityManagement.getTypeName();
@ -644,8 +643,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
@SuppressWarnings("rawtypes")
EntityManagement entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
EntityManagement<?,?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
oDatabaseDocument, vertex);
try {
@ -655,8 +653,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
JsonNode jsonNode;
if(includeRelationInResult) {
@SuppressWarnings("rawtypes")
RelationManagement relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(),
RelationManagement<?,?> relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(),
oDatabaseDocument, edge);
jsonNode = relationManagement.serializeAsJsonNode();
}else {
@ -761,8 +758,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
OVertex vertex = (OVertex) element;
@SuppressWarnings("rawtypes")
EntityManagement entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
EntityManagement<?,?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
oDatabaseDocument, vertex);
try {
if(constraint.containsKey(Entity.HEADER_PROPERTY + "." + Header.UUID_PROPERTY)) {

View File

@ -16,10 +16,12 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
import org.gcube.informationsystem.types.reference.entities.FacetType;
import com.orientechnologies.orient.core.db.document.ODatabaseDocument;
import com.orientechnologies.orient.core.record.ODirection;
import com.orientechnologies.orient.core.record.OEdge;
import com.orientechnologies.orient.core.record.OVertex;
/**
@ -27,6 +29,7 @@ import com.orientechnologies.orient.core.record.OVertex;
*/
public class FacetManagement extends EntityManagement<Facet, FacetType> {
protected ConsistsOfManagement consistsOfManagement;
protected ResourceManagement resourceManagement;
public FacetManagement() {
@ -79,6 +82,14 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
@Override
protected void reallyDelete() throws FacetNotFoundException, ResourceRegistryException {
if(consistsOfManagement==null) {
OEdge oEdge = getElement().getEdges(ODirection.IN).iterator().next();
consistsOfManagement = new ConsistsOfManagement();
consistsOfManagement.setElement(oEdge);
consistsOfManagement.setTargetEntityManagement(this);
affectedInstances.put(uuid, consistsOfManagement.serializeSelfAsJsonNode());
}
if(entryPoint) {
OVertex oVertex = getElement().getVertices(ODirection.IN).iterator().next();
resourceManagement = new ResourceManagement();

View File

@ -755,8 +755,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
continue;
}
@SuppressWarnings("unchecked")
RelationManagement<T, TET> relationManagement = (RelationManagement<T, TET>) ElementManagementUtility.getRelationManagement(getWorkingContext(),
RelationManagement<?, ?> relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(),
oDatabaseDocument, edge);
visitedSourceResources = relationManagement.fullSerialize(visitedSourceResources);
}

View File

@ -75,8 +75,7 @@ public class QueryImpl implements Query {
if(raw) {
jsonNode = Utility.toJsonNode(element, false);
} else {
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument,
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument,
element);
jsonNode = erManagement.serializeAsJsonNode();
}

View File

@ -121,8 +121,7 @@ public class Access extends BaseRest {
checkHierarchicalMode();
checkIncludeInstancesContexts();
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
return erManagement.all(polymorphic);
}
@ -142,8 +141,7 @@ public class Access extends BaseRest {
checkHierarchicalMode();
checkIncludeInstancesContexts();
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
try {
erManagement.setUUID(UUID.fromString(uuid));
@ -203,8 +201,7 @@ public class Access extends BaseRest {
logger.info("Requested to get contexts of {} with UUID {}", type, instanceId);
CalledMethodProvider.instance.set("getInstanceContexts");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setUUID(UUID.fromString(instanceId));
return erManagement.getContexts();
}

View File

@ -53,8 +53,7 @@ public class InstancesManager extends BaseRest {
checkHierarchicalMode();
checkIncludeInstancesContexts();
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
return erManagement.all(polymorphic);
}
@ -113,8 +112,7 @@ public class InstancesManager extends BaseRest {
checkHierarchicalMode();
checkIncludeInstancesContexts();
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setElementType(type);
erManagement.setUUID(UUID.fromString(uuid));
return erManagement.read().toString();
@ -157,8 +155,7 @@ public class InstancesManager extends BaseRest {
logger.info("Requested to delete {} with id {}", type, uuid);
CalledMethodProvider.instance.set("deleteInstance");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
erManagement.setUUID(UUID.fromString(uuid));
erManagement.delete();