Renamed Class

This commit is contained in:
Luca Frosini 2021-10-22 10:24:16 +02:00
parent b9d1a43520
commit d2324da565
6 changed files with 71 additions and 73 deletions

View File

@ -6,7 +6,7 @@ import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.model.reference.properties.Header;
import org.gcube.informationsystem.model.reference.properties.Property;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.types.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.utils.discovery.SchemaAction;
import org.slf4j.Logger;
@ -23,9 +23,9 @@ public class SchemaActionImpl implements SchemaAction {
public <R extends RelationElement<? extends EntityElement,? extends EntityElement>> void manageRelationClass(Class<R> r)
throws Exception {
try {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeAndTypeName(r);
schemaManagement.create();
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeAndTypeName(r);
typeManagement.create();
} catch(SchemaAlreadyPresentException sape) {
logger.warn("{} already exists. It will be ignored", TypeMapper.getType(r));
} catch(Exception ex) {
@ -37,9 +37,9 @@ public class SchemaActionImpl implements SchemaAction {
@Override
public <E extends EntityElement> void manageEntityClass(Class<E> e) throws Exception {
try {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeAndTypeName(e);
schemaManagement.create();
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeAndTypeName(e);
typeManagement.create();
} catch(SchemaAlreadyPresentException sape) {
logger.warn("{} already exists. It will be ignored", TypeMapper.getType(e));
} catch(Exception ex) {
@ -51,12 +51,12 @@ public class SchemaActionImpl implements SchemaAction {
@Override
public <P extends PropertyElement> void managePropertyClass(Class<P> p) throws Exception {
try {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeAndTypeName(p);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeAndTypeName(p);
if(p.equals(Property.class) || p.equals(Header.class) ) {
((SchemaManagement) schemaManagement).setSkipTypeDefinitionCreation(true);
((TypeManagement) typeManagement).setSkipTypeDefinitionCreation(true);
}
schemaManagement.create();
typeManagement.create();
} catch(SchemaAlreadyPresentException sape) {
logger.warn("{} already exists. It will be ignored", TypeMapper.getType(p));
} catch(Exception ex) {

View File

@ -39,7 +39,7 @@ import org.gcube.informationsystem.resourceregistry.instances.model.entities.Res
import org.gcube.informationsystem.resourceregistry.query.Query;
import org.gcube.informationsystem.resourceregistry.query.QueryImpl;
import org.gcube.informationsystem.resourceregistry.query.json.JsonQuery;
import org.gcube.informationsystem.resourceregistry.types.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
@ -102,9 +102,9 @@ public class Access extends BaseRest {
logger.info("Requested Schema for type {}", type);
CalledMethodProvider.instance.set("readType");
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(type);
List<Type> types = schemaManagement.read(polymorphic);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(type);
List<Type> types = typeManagement.read(polymorphic);
try {
return TypeMapper.serializeTypeDefinitions(types);
}catch (Exception e) {

View File

@ -22,7 +22,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
import org.gcube.informationsystem.resourceregistry.api.rest.TypePath;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.types.SchemaManagement;
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.slf4j.Logger;
@ -57,7 +57,7 @@ public class TypeManager {
logger.info("Requested {} creation with schema {}", typeName, json);
CalledMethodProvider.instance.set("createType");
SchemaManagement schemaManagement = new SchemaManagement();
TypeManagement schemaManagement = new TypeManagement();
schemaManagement.setTypeName(typeName);
schemaManagement.setJson(json);
String ret = schemaManagement.create();
@ -79,7 +79,7 @@ public class TypeManager {
logger.info("Requested Schema for type {}", type);
CalledMethodProvider.instance.set("readType");
SchemaManagement schemaManagement = new SchemaManagement();
TypeManagement schemaManagement = new TypeManagement();
schemaManagement.setTypeName(type);
List<Type> types = schemaManagement.read(polymorphic);
try {

View File

@ -175,7 +175,7 @@ public class CachedType<T extends Type> {
@SuppressWarnings("unchecked")
private T internalGetType() throws SchemaNotFoundException, SchemaException, ResourceRegistryException {
if(type==null) {
ElementManagement<?,?> erManagement = SchemaManagement.getTypeManagement(internalGetOClass());
ElementManagement<?,?> erManagement = TypeManagement.getTypeManagement(internalGetOClass());
String typeString = erManagement.read();
try {
type = (T) TypeMapper.deserializeTypeDefinition(typeString);

View File

@ -68,9 +68,9 @@ import com.orientechnologies.orient.core.record.OElement;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public class SchemaManagement {
public class TypeManagement {
private static Logger logger = LoggerFactory.getLogger(SchemaManagement.class);
private static Logger logger = LoggerFactory.getLogger(TypeManagement.class);
protected String typeName;
protected String json;
@ -106,7 +106,7 @@ public class SchemaManagement {
}
}
public SchemaManagement() {
public TypeManagement() {
this.skipTypeDefinitionCreation = false;
}

View File

@ -60,9 +60,9 @@ public class SchemaManagementImplTest extends ContextTest {
@Test
public void getPropertyTypeSchema() throws Exception {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(Property.NAME);
List<Type> types = schemaManagement.read(false);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(Property.NAME);
List<Type> types = typeManagement.read(false);
String json = TypeMapper.serializeTypeDefinitions(types);
logger.debug(json);
}
@ -86,9 +86,9 @@ public class SchemaManagementImplTest extends ContextTest {
@Test
public void getFacetSchema() throws Exception {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(ContactFacet.NAME);
List<Type> types = schemaManagement.read(false);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(ContactFacet.NAME);
List<Type> types = typeManagement.read(false);
String json = TypeMapper.serializeTypeDefinitions(types);
logger.info(json);
List<Type> typeDefinitions = TypeMapper.deserializeTypeDefinitions(json);
@ -109,14 +109,13 @@ public class SchemaManagementImplTest extends ContextTest {
Class<? extends Resource> clz = Resource.class;
String json = TypeMapper.serializeType(clz);
logger.info(json);
// new SchemaManagementImpl().registerFacetSchema(json);
}
@Test
public void getResourceSchema() throws Exception {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(Actor.NAME);
List<Type> types = schemaManagement.read(false);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(Actor.NAME);
List<Type> types = typeManagement.read(false);
String json = TypeMapper.serializeTypeDefinitions(types);
logger.trace(json);
}
@ -126,7 +125,6 @@ public class SchemaManagementImplTest extends ContextTest {
Class<? extends Element> clz = Hosts.class;
String json = TypeMapper.serializeType(clz);
logger.trace(json);
// new SchemaManagementImpl().registerFacetSchema(json);
}
@Test
@ -135,9 +133,9 @@ public class SchemaManagementImplTest extends ContextTest {
boolean includeSubTypes = true;
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(Resource.NAME);
List<Type> types = schemaManagement.read(includeSubTypes);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(Resource.NAME);
List<Type> types = typeManagement.read(includeSubTypes);
String list = TypeMapper.serializeTypeDefinitions(types);
logger.info("{} list : {}", Resource.NAME, list);
}
@ -148,9 +146,9 @@ public class SchemaManagementImplTest extends ContextTest {
boolean includeSubTypes = true;
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(Facet.NAME);
List<Type> types = schemaManagement.read(includeSubTypes);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(Facet.NAME);
List<Type> types = typeManagement.read(includeSubTypes);
String list = TypeMapper.serializeTypeDefinitions(types);
logger.info("{} list : {}", Facet.NAME, list);
}
@ -161,9 +159,9 @@ public class SchemaManagementImplTest extends ContextTest {
boolean includeSubTypes = true;
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(ConsistsOf.NAME);
List<Type> types = schemaManagement.read(includeSubTypes);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(ConsistsOf.NAME);
List<Type> types = typeManagement.read(includeSubTypes);
String list = TypeMapper.serializeTypeDefinitions(types);
logger.info("{} list : {}", ConsistsOf.NAME, list);
}
@ -174,9 +172,9 @@ public class SchemaManagementImplTest extends ContextTest {
boolean includeSubTypes = true;
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(IsRelatedTo.NAME);
List<Type> types = schemaManagement.read(includeSubTypes);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(IsRelatedTo.NAME);
List<Type> types = typeManagement.read(includeSubTypes);
String list = TypeMapper.serializeTypeDefinitions(types);
logger.info("{} list : {}", IsRelatedTo.NAME, list);
@ -189,28 +187,28 @@ public class SchemaManagementImplTest extends ContextTest {
boolean includeSubTypes = true;
SchemaManagement schemaManagement = new SchemaManagement();
TypeManagement typeManagement = new TypeManagement();
try {
schemaManagement.setTypeName(PropertyElement.NAME);
schemaManagement.read(includeSubTypes);
typeManagement.setTypeName(PropertyElement.NAME);
typeManagement.read(includeSubTypes);
throw new Exception("Should not be allowed to get " + PropertyElement.NAME + " schema");
} catch (SchemaException e) {
}
try {
schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(Entity.NAME);
schemaManagement.read(includeSubTypes);
typeManagement = new TypeManagement();
typeManagement.setTypeName(Entity.NAME);
typeManagement.read(includeSubTypes);
throw new Exception("Should not be allowed to get " + Entity.NAME + " schema");
} catch (SchemaException e) {
}
try {
schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(Relation.NAME);
schemaManagement.read(includeSubTypes);
typeManagement = new TypeManagement();
typeManagement.setTypeName(Relation.NAME);
typeManagement.read(includeSubTypes);
throw new Exception("Should not be allowed to get " + Relation.NAME + " schema");
} catch (SchemaException e) {
@ -221,19 +219,19 @@ public class SchemaManagementImplTest extends ContextTest {
protected String create(Class<? extends Element> clz)
throws SchemaAlreadyPresentException, SchemaException, Exception {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeAndTypeName(clz);
String ret = schemaManagement.create();
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeAndTypeName(clz);
String ret = typeManagement.create();
logger.debug(ret);
return ret;
}
protected String update(Class<? extends Element> clz, boolean skipVersionCheckOnUpdate)
throws SchemaAlreadyPresentException, SchemaException, SchemaNotFoundException, Exception {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeAndTypeName(clz);
schemaManagement.setSkipVersionCheckOnUpdate(skipVersionCheckOnUpdate);
String ret = schemaManagement.update();
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeAndTypeName(clz);
typeManagement.setSkipVersionCheckOnUpdate(skipVersionCheckOnUpdate);
String ret = typeManagement.update();
logger.debug(ret);
return ret;
}
@ -305,12 +303,12 @@ public class SchemaManagementImplTest extends ContextTest {
@Test
public void deleteTestFacetType() throws Exception {
SchemaManagement schemaManagement = new SchemaManagement();
TypeManagement typeManagement = new TypeManagement();
String typeName = TestFacet.NAME;
schemaManagement.setTypeName(typeName);
typeManagement.setTypeName(typeName);
try {
logger.info("Going to delete {}", typeName);
schemaManagement.delete(AccessType.FACET);
typeManagement.delete(AccessType.FACET);
logger.info("Deleted {}", typeName);
} catch (SchemaNotFoundException e) {
// The test has been failed before creating the type
@ -322,12 +320,12 @@ public class SchemaManagementImplTest extends ContextTest {
@Test
public void createUpdateDeleteFacetType() throws Exception {
SchemaManagement schemaManagement = new SchemaManagement();
TypeManagement typeManagement = new TypeManagement();
String typeName = TestFacet.NAME;
schemaManagement.setTypeName(typeName);
typeManagement.setTypeName(typeName);
try {
logger.info("Going to delete {}", typeName);
schemaManagement.delete(AccessType.FACET);
typeManagement.delete(AccessType.FACET);
logger.info("Deleted {}", typeName);
} catch (SchemaNotFoundException e) {
// Removing the test type in case of a previous failure on test occurred
@ -368,12 +366,12 @@ public class SchemaManagementImplTest extends ContextTest {
} catch (Exception e) {
throw e;
} finally {
schemaManagement = new SchemaManagement();
typeManagement = new TypeManagement();
typeName = TestFacet.NAME;
schemaManagement.setTypeName(typeName);
typeManagement.setTypeName(typeName);
try {
logger.info("Going to delete {}", typeName);
schemaManagement.delete(AccessType.FACET);
typeManagement.delete(AccessType.FACET);
logger.info("Deleted {}", typeName);
} catch (SchemaNotFoundException e) {
// The test has been failed before creating the type
@ -386,8 +384,8 @@ public class SchemaManagementImplTest extends ContextTest {
@Test(expected=SchemaNotFoundException.class)
public void deleteFacetType() throws Exception {
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(TestFacet.NAME);
schemaManagement.delete(AccessType.FACET);
TypeManagement typeManagement = new TypeManagement();
typeManagement.setTypeName(TestFacet.NAME);
typeManagement.delete(AccessType.FACET);
}
}