Fixed bug introduced on function merging. Set a function to static.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@134654 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2016-11-24 09:40:51 +00:00
parent 0b1bd22e4e
commit 87cd63d2b6
2 changed files with 16 additions and 19 deletions

View File

@ -62,8 +62,6 @@ import com.tinkerpop.blueprints.impls.orient.OrientVertex;
*/
public class EntityManagementImpl implements EntityManagement {
// TODO This Class is too long please refactoring is needed
private static Logger logger = LoggerFactory
.getLogger(EntityManagementImpl.class);
@ -102,9 +100,8 @@ public class EntityManagementImpl implements EntityManagement {
String classProperty = getClassProperty(jsonNode);
SchemaManagementImpl schemaManagement = new SchemaManagementImpl();
try {
schemaManagement.getTypeSchema(classProperty, classProperty);
SchemaManagementImpl.getTypeSchema(classProperty, classProperty);
} catch (SchemaNotFoundException e) {
throw e;
}
@ -159,9 +156,8 @@ public class EntityManagementImpl implements EntityManagement {
String classProperty = getClassProperty(jsonNode);
if (relationType.compareTo(classProperty) != 0) {
SchemaManagementImpl schemaManagement = new SchemaManagementImpl();
try {
schemaManagement.getTypeSchema(relationType, classProperty);
SchemaManagementImpl.getTypeSchema(relationType, classProperty);
} catch (SchemaNotFoundException e) {
throw e;
}
@ -194,9 +190,8 @@ public class EntityManagementImpl implements EntityManagement {
// Complex type
String type = getClassProperty(jsonNode);
SchemaManagementImpl schemaManagement = new SchemaManagementImpl();
try {
schemaManagement.getTypeSchema(type, Embedded.NAME);
SchemaManagementImpl.getTypeSchema(type, Embedded.NAME);
} catch (SchemaNotFoundException e) {
throw e;
}
@ -451,9 +446,8 @@ public class EntityManagementImpl implements EntityManagement {
try {
SchemaManagementImpl schemaManagement = new SchemaManagementImpl();
try {
schemaManagement.getTypeSchema(entityType,
SchemaManagementImpl.getTypeSchema(entityType,
entity.getSimpleName());
} catch (SchemaNotFoundException e) {
throw e;
@ -605,9 +599,8 @@ public class EntityManagementImpl implements EntityManagement {
+ " Type cannot be empty or null");
}
SchemaManagementImpl schemaManagement = new SchemaManagementImpl();
try {
schemaManagement.getTypeSchema(relationType,
SchemaManagementImpl.getTypeSchema(relationType,
relationBaseClass.getSimpleName());
} catch (SchemaNotFoundException e) {
throw e;
@ -694,9 +687,8 @@ public class EntityManagementImpl implements EntityManagement {
+ " Type cannot be empty or null");
}
SchemaManagementImpl schemaManagement = new SchemaManagementImpl();
try {
schemaManagement.getTypeSchema(relationType,
SchemaManagementImpl.getTypeSchema(relationType,
relationClass.getSimpleName());
} catch (SchemaNotFoundException e) {
throw e;
@ -1104,8 +1096,7 @@ public class EntityManagementImpl implements EntityManagement {
String edgeType = edge.getLabel();
try {
SchemaManagementImpl schemaManagement = new SchemaManagementImpl();
schemaManagement.getTypeSchema(edgeType, ConsistsOf.NAME);
SchemaManagementImpl.getTypeSchema(edgeType, ConsistsOf.NAME);
JSONObject jsonObjectEdge = Utility.toJsonObject(
(OrientEdge) edge, true);

View File

@ -33,6 +33,7 @@ import com.orientechnologies.orient.core.metadata.schema.OProperty;
import com.orientechnologies.orient.core.metadata.schema.OSchema;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.tinkerpop.blueprints.impls.orient.OrientElementType;
import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
@ -55,7 +56,7 @@ public class SchemaManagementImpl implements SchemaManagement {
return oSchema.getClass(entityType);
}
protected OClass getTypeSchema(String type, String baseType)
protected static OClass getTypeSchema(String type, String baseType)
throws SchemaNotFoundException {
OrientGraphFactory orientGraphFactory = SecurityContextMapper
.getSecurityContextFactory(
@ -90,7 +91,7 @@ public class SchemaManagementImpl implements SchemaManagement {
}
}
protected static String serializeOClass(OClass oClass) {
protected static String serializeOClass(OClass oClass) throws SchemaException {
ODocument oDocument = ((OClassImpl) oClass).toStream();
String json = oDocument.toJSON();
logger.trace("Requested type serialization is {}", json);
@ -234,7 +235,12 @@ public class SchemaManagementImpl implements SchemaManagement {
}
}
String ret = serializeOClass(oClass);
OClass toBeSerializedOClass = oClass;
if(oClass instanceof OrientElementType){
toBeSerializedOClass = getEntityOClass(orientGraphNoTx, typeDefinition.getName());
}
String ret = serializeOClass(toBeSerializedOClass);
logger.info("{} type registered successfully: {}", baseType, jsonSchema);
return ret;