Renaming objects
This commit is contained in:
parent
1f6d21b9a0
commit
5e607461f1
|
@ -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;
|
||||||
|
|
||||||
|
}
|
|
@ -40,13 +40,12 @@ public class DiscoveryUtility {
|
||||||
return packages;
|
return packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void discover(SchemaAction schemaAction) throws Exception {
|
public static void discover(DiscoveredElementAction schemaAction) throws Exception {
|
||||||
List<Package> packages = DiscoveryUtility.discoverPackages();
|
List<Package> packages = DiscoveryUtility.discoverPackages();
|
||||||
DiscoveryUtility.manageISM(schemaAction , packages);
|
DiscoveryUtility.manageISM(schemaAction , packages);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public static void manageISM(DiscoveredElementAction dea, Package... packages) throws Exception {
|
||||||
public static void manageISM(SchemaAction schemaAction, Package... packages) throws Exception {
|
|
||||||
Discovery<PropertyElement> propertyDiscovery = new Discovery<>(PropertyElement.class);
|
Discovery<PropertyElement> propertyDiscovery = new Discovery<>(PropertyElement.class);
|
||||||
if(Objects.nonNull(packages)) {
|
if(Objects.nonNull(packages)) {
|
||||||
Arrays.stream(packages).forEach(p -> propertyDiscovery.addPackage(p));
|
Arrays.stream(packages).forEach(p -> propertyDiscovery.addPackage(p));
|
||||||
|
@ -54,7 +53,7 @@ public class DiscoveryUtility {
|
||||||
propertyDiscovery.discover();
|
propertyDiscovery.discover();
|
||||||
for(Class<? extends PropertyElement> property : propertyDiscovery.getDiscovered()) {
|
for(Class<? extends PropertyElement> property : propertyDiscovery.getDiscovered()) {
|
||||||
logger.trace("Going to manage : {}", property);
|
logger.trace("Going to manage : {}", property);
|
||||||
schemaAction.managePropertyClass(property);
|
dea.manageElementType(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
Discovery<EntityElement> entityDiscovery = new Discovery<>(EntityElement.class);
|
Discovery<EntityElement> entityDiscovery = new Discovery<>(EntityElement.class);
|
||||||
|
@ -65,7 +64,7 @@ public class DiscoveryUtility {
|
||||||
|
|
||||||
for(Class<? extends EntityElement> entity : entityDiscovery.getDiscovered()) {
|
for(Class<? extends EntityElement> entity : entityDiscovery.getDiscovered()) {
|
||||||
logger.trace("Going to manage : {}", entity);
|
logger.trace("Going to manage : {}", entity);
|
||||||
schemaAction.manageEntityClass(entity);
|
dea.manageElementType(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
@ -77,11 +76,11 @@ public class DiscoveryUtility {
|
||||||
for(@SuppressWarnings("rawtypes")
|
for(@SuppressWarnings("rawtypes")
|
||||||
Class<? extends RelationElement> relation : relationDiscovery.getDiscovered()) {
|
Class<? extends RelationElement> relation : relationDiscovery.getDiscovered()) {
|
||||||
logger.trace("Going to manage : {}", relation);
|
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) {
|
if(Objects.nonNull(packages) && packages.size() > 0) {
|
||||||
manageISM(schemaAction, packages.stream().toArray(Package[]::new));
|
manageISM(schemaAction, packages.stream().toArray(Package[]::new));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -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;
|
|
||||||
|
|
||||||
}
|
|
|
@ -30,7 +30,7 @@ import org.gcube.informationsystem.base.reference.AccessType;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.discovery.DiscoveryUtility;
|
import org.gcube.informationsystem.discovery.DiscoveryUtility;
|
||||||
import org.gcube.informationsystem.discovery.RegistrationProvider;
|
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.TypeMapper;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -101,7 +101,7 @@ public abstract class ElementMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerPackages(List<Package> packages) {
|
public static void registerPackages(List<Package> packages) {
|
||||||
SchemaAction schemaAction = new ElementMappingAction();
|
DiscoveredElementAction schemaAction = new ElementMappingAction();
|
||||||
try {
|
try {
|
||||||
DiscoveryUtility.manageISM(schemaAction, packages);
|
DiscoveryUtility.manageISM(schemaAction, packages);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
@ -110,7 +110,7 @@ public abstract class ElementMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerPackages(Package... packages) {
|
public static void registerPackages(Package... packages) {
|
||||||
SchemaAction schemaAction = new ElementMappingAction();
|
DiscoveredElementAction schemaAction = new ElementMappingAction();
|
||||||
try {
|
try {
|
||||||
DiscoveryUtility.manageISM(schemaAction, packages);
|
DiscoveryUtility.manageISM(schemaAction, packages);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
|
|
@ -3,36 +3,17 @@
|
||||||
*/
|
*/
|
||||||
package org.gcube.informationsystem.serialization;
|
package org.gcube.informationsystem.serialization;
|
||||||
|
|
||||||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
import org.gcube.informationsystem.discovery.DiscoveredElementAction;
|
||||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
|
||||||
import org.gcube.informationsystem.discovery.SchemaAction;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
class ElementMappingAction implements SchemaAction {
|
class ElementMappingAction implements DiscoveredElementAction {
|
||||||
|
|
||||||
public ElementMappingAction(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <P extends PropertyElement> void managePropertyClass(Class<P> e)
|
public <E extends Element> void manageElementType(Class<E> e) throws Exception {
|
||||||
throws Exception {
|
|
||||||
ElementMapper.registerSubtype(e);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||||
import org.gcube.informationsystem.discovery.Discovery;
|
import org.gcube.informationsystem.discovery.Discovery;
|
||||||
import org.gcube.informationsystem.discovery.DiscoveryUtility;
|
import org.gcube.informationsystem.discovery.DiscoveryUtility;
|
||||||
import org.gcube.informationsystem.discovery.RegistrationProvider;
|
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.TypeMapper;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||||
|
@ -98,7 +98,7 @@ public class ISMDiscoveryTest {
|
||||||
packages.addAll(registrationProvider.getPackagesToRegister());
|
packages.addAll(registrationProvider.getPackagesToRegister());
|
||||||
}
|
}
|
||||||
|
|
||||||
SchemaAction schemaAction = new SchemaAction() {
|
DiscoveredElementAction schemaAction = new DiscoveredElementAction() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <R extends RelationElement<? extends EntityElement, ? extends EntityElement>> void manageRelationClass(
|
public <R extends RelationElement<? extends EntityElement, ? extends EntityElement>> void manageRelationClass(
|
||||||
|
|
Loading…
Reference in New Issue