Added support to specify Context implementation to GCubeContext
This commit is contained in:
parent
2d5c9247cc
commit
e8ade3d3ea
|
@ -4,7 +4,11 @@ import java.util.Collection;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.discovery.RegistrationProvider;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.gcube.resourcemanagement.contexts.impl.entities.GCubeContext;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.facets.SoftwareFacet;
|
||||
import org.gcube.resourcemanagement.model.reference.entities.resources.EService;
|
||||
import org.gcube.resourcemanagement.model.reference.properties.ValueSchema;
|
||||
|
@ -18,8 +22,17 @@ public class GCubeModelRegistrationProvider implements RegistrationProvider {
|
|||
|
||||
public static final String GCUBE_MODEL_NAME = "gCube Model";
|
||||
|
||||
public <E extends Element, EImpl extends E> void registerContextOverride() {
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<E> clz = (Class<E>) Context.class;
|
||||
@SuppressWarnings("unchecked")
|
||||
Class<EImpl> implClz = (Class<EImpl>) GCubeContext.class;
|
||||
ElementMapper.addDynamicAssociation(clz, implClz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Package> getPackagesToRegister() {
|
||||
registerContextOverride();
|
||||
Set<Package> packages = new HashSet<>();
|
||||
packages.add(ValueSchema.class.getPackage());
|
||||
packages.add(SoftwareFacet.class.getPackage());
|
||||
|
|
|
@ -124,6 +124,10 @@ public class PolymorphismTest {
|
|||
Context c = new ContextImpl("test");
|
||||
c.setID(UUID.randomUUID());
|
||||
c.setState("created");
|
||||
String s = c.toString();
|
||||
logger.debug(s);
|
||||
|
||||
c = ElementMapper.unmarshal(Context.class, s);
|
||||
logger.debug(c.toString());
|
||||
|
||||
GCubeContext gcubeContext = new GCubeContext(c);
|
||||
|
|
Loading…
Reference in New Issue