Renaming objects

This commit is contained in:
Luca Frosini 2023-02-03 14:44:42 +01:00
parent 1f6d21b9a0
commit 5e607461f1
6 changed files with 30 additions and 56 deletions

View File

@ -0,0 +1,15 @@
/**
*
*/
package org.gcube.informationsystem.discovery;
import org.gcube.informationsystem.base.reference.Element;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public interface DiscoveredElementAction {
public <E extends Element> void manageElementType(Class<E> e) throws Exception;
}

View File

@ -40,13 +40,12 @@ public class DiscoveryUtility {
return packages;
}
public static void discover(SchemaAction schemaAction) throws Exception {
public static void discover(DiscoveredElementAction schemaAction) throws Exception {
List<Package> packages = DiscoveryUtility.discoverPackages();
DiscoveryUtility.manageISM(schemaAction , packages);
}
@SuppressWarnings("unchecked")
public static void manageISM(SchemaAction schemaAction, Package... packages) throws Exception {
public static void manageISM(DiscoveredElementAction dea, Package... packages) throws Exception {
Discovery<PropertyElement> propertyDiscovery = new Discovery<>(PropertyElement.class);
if(Objects.nonNull(packages)) {
Arrays.stream(packages).forEach(p -> propertyDiscovery.addPackage(p));
@ -54,7 +53,7 @@ public class DiscoveryUtility {
propertyDiscovery.discover();
for(Class<? extends PropertyElement> property : propertyDiscovery.getDiscovered()) {
logger.trace("Going to manage : {}", property);
schemaAction.managePropertyClass(property);
dea.manageElementType(property);
}
Discovery<EntityElement> entityDiscovery = new Discovery<>(EntityElement.class);
@ -65,7 +64,7 @@ public class DiscoveryUtility {
for(Class<? extends EntityElement> entity : entityDiscovery.getDiscovered()) {
logger.trace("Going to manage : {}", entity);
schemaAction.manageEntityClass(entity);
dea.manageElementType(entity);
}
@SuppressWarnings("rawtypes")
@ -77,11 +76,11 @@ public class DiscoveryUtility {
for(@SuppressWarnings("rawtypes")
Class<? extends RelationElement> relation : relationDiscovery.getDiscovered()) {
logger.trace("Going to manage : {}", relation);
schemaAction.manageRelationClass(relation);
dea.manageElementType(relation);
}
}
public static void manageISM(SchemaAction schemaAction, List<Package> packages) throws Exception {
public static void manageISM(DiscoveredElementAction schemaAction, List<Package> packages) throws Exception {
if(Objects.nonNull(packages) && packages.size() > 0) {
manageISM(schemaAction, packages.stream().toArray(Package[]::new));
} else {

View File

@ -1,21 +0,0 @@
/**
*
*/
package org.gcube.informationsystem.discovery;
import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.base.reference.relations.RelationElement;
/**
* @author Luca Frosini (ISTI - CNR)
*/
public interface SchemaAction {
public <P extends PropertyElement> void managePropertyClass(Class<P> p) throws Exception;
public <E extends EntityElement> void manageEntityClass(Class<E> e) throws Exception;
public <R extends RelationElement<? extends EntityElement, ? extends EntityElement>> void manageRelationClass(Class<R> r) throws Exception;
}

View File

@ -30,7 +30,7 @@ import org.gcube.informationsystem.base.reference.AccessType;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.discovery.DiscoveryUtility;
import org.gcube.informationsystem.discovery.RegistrationProvider;
import org.gcube.informationsystem.discovery.SchemaAction;
import org.gcube.informationsystem.discovery.DiscoveredElementAction;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.slf4j.Logger;
@ -101,7 +101,7 @@ public abstract class ElementMapper {
}
public static void registerPackages(List<Package> packages) {
SchemaAction schemaAction = new ElementMappingAction();
DiscoveredElementAction schemaAction = new ElementMappingAction();
try {
DiscoveryUtility.manageISM(schemaAction, packages);
} catch(Exception e) {
@ -110,7 +110,7 @@ public abstract class ElementMapper {
}
public static void registerPackages(Package... packages) {
SchemaAction schemaAction = new ElementMappingAction();
DiscoveredElementAction schemaAction = new ElementMappingAction();
try {
DiscoveryUtility.manageISM(schemaAction, packages);
} catch(Exception e) {

View File

@ -3,36 +3,17 @@
*/
package org.gcube.informationsystem.serialization;
import org.gcube.informationsystem.base.reference.entities.EntityElement;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.discovery.SchemaAction;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.discovery.DiscoveredElementAction;
/**
* @author Luca Frosini (ISTI - CNR)
*/
class ElementMappingAction implements SchemaAction {
class ElementMappingAction implements DiscoveredElementAction {
public ElementMappingAction(){
}
@Override
public <P extends PropertyElement> void managePropertyClass(Class<P> e)
throws Exception {
public <E extends Element> void manageElementType(Class<E> e) throws Exception {
ElementMapper.registerSubtype(e);
}
@Override
public <E extends EntityElement> void manageEntityClass(Class<E> e)
throws Exception {
ElementMapper.registerSubtype(e);
}
@Override
public <R extends RelationElement<? extends EntityElement, ? extends EntityElement>> void manageRelationClass(
Class<R> r) throws Exception {
ElementMapper.registerSubtype(r);
}
}

View File

@ -13,7 +13,7 @@ import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.discovery.Discovery;
import org.gcube.informationsystem.discovery.DiscoveryUtility;
import org.gcube.informationsystem.discovery.RegistrationProvider;
import org.gcube.informationsystem.discovery.SchemaAction;
import org.gcube.informationsystem.discovery.DiscoveredElementAction;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
@ -98,7 +98,7 @@ public class ISMDiscoveryTest {
packages.addAll(registrationProvider.getPackagesToRegister());
}
SchemaAction schemaAction = new SchemaAction() {
DiscoveredElementAction schemaAction = new DiscoveredElementAction() {
@Override
public <R extends RelationElement<? extends EntityElement, ? extends EntityElement>> void manageRelationClass(