Fixing Publisher
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@131464 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3a35ea17a0
commit
54f731c69a
|
@ -20,18 +20,14 @@ public interface ResourceRegistryPublisher {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public <C extends ConsistsOf<Resource, Facet>> C createConsistsOf(Class<C> consistsOfClass, C consistsOf);
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(Class<C> consistsOfClass, C consistsOf);
|
||||||
|
|
||||||
//public <C extends ConsistsOf<Resource, Facet>> C updateConsistsOf(C consistsOf);
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(C consistsOf);
|
||||||
|
|
||||||
public <C extends ConsistsOf<Resource, Facet>> boolean deleteConsistsOf(C consistsOf);
|
|
||||||
|
|
||||||
|
|
||||||
public <I extends IsRelatedTo<Resource, Resource>> I createIsRelatedTo(Class<I> isRelatedToClass, I isRelatedTo);
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(Class<I> isRelatedToClass, I isRelatedTo);
|
||||||
|
|
||||||
//public <I extends IsRelatedTo<Resource, Resource>> I updateIsRelatedTo(I isRelatedTo);
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> boolean deleteIsRelatedTo(I isRelatedTo);
|
||||||
|
|
||||||
public <I extends IsRelatedTo<Resource, Resource>> boolean deleteIsRelatedTo(I isRelatedTo);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -369,7 +369,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <C extends ConsistsOf<Resource, Facet>> C createConsistsOf(
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(
|
||||||
Class<C> consistsOfClass, C consistsOf) {
|
Class<C> consistsOfClass, C consistsOf) {
|
||||||
try {
|
try {
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
@ -402,16 +402,8 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public <C extends ConsistsOf<Resource, Facet>> C updateConsistsOf(
|
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(
|
||||||
C consistsOf) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <C extends ConsistsOf<Resource, Facet>> boolean deleteConsistsOf(
|
|
||||||
C consistsOf) {
|
C consistsOf) {
|
||||||
try {
|
try {
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
|
@ -434,7 +426,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <I extends IsRelatedTo<Resource, Resource>> I createIsRelatedTo(
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
|
||||||
Class<I> isRelatedToClass, I isRelatedTo) {
|
Class<I> isRelatedToClass, I isRelatedTo) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -468,16 +460,8 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@Override
|
@Override
|
||||||
public <I extends IsRelatedTo<Resource, Resource>> I updateIsRelatedTo(I isRelatedTo) {
|
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> boolean deleteIsRelatedTo(I isRelatedTo) {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public <I extends IsRelatedTo<Resource, Resource>> boolean deleteIsRelatedTo(I isRelatedTo) {
|
|
||||||
try {
|
try {
|
||||||
StringWriter stringWriter = new StringWriter();
|
StringWriter stringWriter = new StringWriter();
|
||||||
stringWriter.append(PATH_SEPARATOR);
|
stringWriter.append(PATH_SEPARATOR);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.gcube.informationsystem.impl.entity.resource.EServiceImpl;
|
||||||
import org.gcube.informationsystem.impl.entity.resource.HostingNodeImpl;
|
import org.gcube.informationsystem.impl.entity.resource.HostingNodeImpl;
|
||||||
import org.gcube.informationsystem.impl.relation.IsIdentifiedByImpl;
|
import org.gcube.informationsystem.impl.relation.IsIdentifiedByImpl;
|
||||||
import org.gcube.informationsystem.impl.relation.isrelatedto.HostsImpl;
|
import org.gcube.informationsystem.impl.relation.isrelatedto.HostsImpl;
|
||||||
|
import org.gcube.informationsystem.impl.utils.Entities;
|
||||||
import org.gcube.informationsystem.model.entity.Facet;
|
import org.gcube.informationsystem.model.entity.Facet;
|
||||||
import org.gcube.informationsystem.model.entity.Resource;
|
import org.gcube.informationsystem.model.entity.Resource;
|
||||||
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
|
import org.gcube.informationsystem.model.entity.facet.CPUFacet;
|
||||||
|
@ -20,9 +21,7 @@ import org.gcube.informationsystem.model.entity.facet.NetworkingFacet;
|
||||||
import org.gcube.informationsystem.model.entity.facet.SoftwareFacet;
|
import org.gcube.informationsystem.model.entity.facet.SoftwareFacet;
|
||||||
import org.gcube.informationsystem.model.entity.resource.EService;
|
import org.gcube.informationsystem.model.entity.resource.EService;
|
||||||
import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
import org.gcube.informationsystem.model.entity.resource.HostingNode;
|
||||||
import org.gcube.informationsystem.model.relation.ConsistsOf;
|
|
||||||
import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
|
import org.gcube.informationsystem.model.relation.IsIdentifiedBy;
|
||||||
import org.gcube.informationsystem.model.relation.IsRelatedTo;
|
|
||||||
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
||||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
|
||||||
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
|
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
|
||||||
|
@ -99,18 +98,21 @@ public class ResourceRegistryPublisherTest {
|
||||||
softwareFacet.setName("resource-registry");
|
softwareFacet.setName("resource-registry");
|
||||||
softwareFacet.setVersion("1.1.0");
|
softwareFacet.setVersion("1.1.0");
|
||||||
|
|
||||||
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(eService, softwareFacet, null);
|
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedByESSF = new IsIdentifiedByImpl<>(eService, softwareFacet, null);
|
||||||
eService.addFacet(isIdentifiedBy);
|
eService.addFacet(isIdentifiedByESSF);
|
||||||
|
|
||||||
|
Entities.registerSubtypes(IsIdentifiedBy.class, SoftwareFacet.class, EService.class);
|
||||||
|
|
||||||
logger.debug("Going to create : {}", eService);
|
logger.debug("Going to create : {}", eService);
|
||||||
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
|
||||||
logger.debug("Created : {}", createdEService);
|
logger.debug("Created : {}", createdEService);
|
||||||
|
|
||||||
|
|
||||||
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) createdEService.getIdentificationFacets().get(0);
|
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) createdEService.getIdentificationFacets().get(0);
|
||||||
logger.debug("Created : {}", softwareFacet);
|
logger.debug("Created : {}", softwareFacet);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
|
||||||
networkingFacet.setIPAddress("146.48.87.183");
|
networkingFacet.setIPAddress("146.48.87.183");
|
||||||
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
|
||||||
|
@ -118,6 +120,7 @@ public class ResourceRegistryPublisherTest {
|
||||||
networkingFacet.setMask("255.255.248.0");
|
networkingFacet.setMask("255.255.248.0");
|
||||||
networkingFacet.setBroadcastAddress("146.48.87.255");
|
networkingFacet.setBroadcastAddress("146.48.87.255");
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Going to create : {}", networkingFacet);
|
logger.debug("Going to create : {}", networkingFacet);
|
||||||
NetworkingFacet createdNetworkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet);
|
NetworkingFacet createdNetworkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet);
|
||||||
logger.debug("Created : {}", createdNetworkingFacet);
|
logger.debug("Created : {}", createdNetworkingFacet);
|
||||||
|
@ -132,13 +135,17 @@ public class ResourceRegistryPublisherTest {
|
||||||
|
|
||||||
hostingNode.addFacet(cpuFacet);
|
hostingNode.addFacet(cpuFacet);
|
||||||
|
|
||||||
isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null);
|
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<>(hostingNode, createdNetworkingFacet, null);
|
||||||
hostingNode.attachFacet(isIdentifiedBy);
|
hostingNode.attachFacet(isIdentifiedByHNNF);
|
||||||
|
|
||||||
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, null);
|
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, null);
|
||||||
|
|
||||||
hostingNode.attachResource(hosts);
|
hostingNode.attachResource(hosts);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Entities.registerSubtypes(HostingNode.class, CPUFacet.class);
|
||||||
|
|
||||||
logger.debug("Going to create : {}", hostingNode);
|
logger.debug("Going to create : {}", hostingNode);
|
||||||
HostingNode createdHostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
|
HostingNode createdHostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
|
||||||
logger.debug("Created : {}", createdHostingNode);
|
logger.debug("Created : {}", createdHostingNode);
|
||||||
|
@ -221,8 +228,7 @@ public class ResourceRegistryPublisherTest {
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Going to delete : {}", createdIsIdentifiedByCPUFacet);
|
logger.debug("Going to delete : {}", createdIsIdentifiedByCPUFacet);
|
||||||
@SuppressWarnings("unchecked")
|
boolean deleted = resourceRegistryPublisher.deleteConsistsOf(createdIsIdentifiedByCPUFacet);
|
||||||
boolean deleted = resourceRegistryPublisher.deleteConsistsOf((ConsistsOf) createdIsIdentifiedByCPUFacet);
|
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,7 +238,7 @@ public class ResourceRegistryPublisherTest {
|
||||||
|
|
||||||
|
|
||||||
logger.debug("Going to delete : {}", createdHosts);
|
logger.debug("Going to delete : {}", createdHosts);
|
||||||
deleted = resourceRegistryPublisher.deleteIsRelatedTo((IsRelatedTo) createdHosts);
|
deleted = resourceRegistryPublisher.deleteIsRelatedTo(createdHosts);
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue