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:
Luca Frosini 2016-09-16 16:38:12 +00:00
parent 3a35ea17a0
commit 54f731c69a
3 changed files with 24 additions and 38 deletions

View File

@ -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<Resource, Facet>> boolean deleteConsistsOf(C consistsOf);
public <C extends ConsistsOf<? extends Resource, ? extends 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<Resource, Resource>> boolean deleteIsRelatedTo(I isRelatedTo);
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> boolean deleteIsRelatedTo(I isRelatedTo);
}

View File

@ -369,7 +369,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
}
@Override
public <C extends ConsistsOf<Resource, Facet>> C createConsistsOf(
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(
Class<C> consistsOfClass, C consistsOf) {
try {
StringWriter stringWriter = new StringWriter();
@ -401,17 +401,9 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
throw new ServiceException(e);
}
}
/*
@Override
public <C extends ConsistsOf<Resource, Facet>> C updateConsistsOf(
C consistsOf) {
return null;
}
*/
@Override
public <C extends ConsistsOf<Resource, Facet>> boolean deleteConsistsOf(
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> boolean deleteConsistsOf(
C consistsOf) {
try {
StringWriter stringWriter = new StringWriter();
@ -434,7 +426,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
}
@Override
public <I extends IsRelatedTo<Resource, Resource>> I createIsRelatedTo(
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> I createIsRelatedTo(
Class<I> isRelatedToClass, I isRelatedTo) {
try {
@ -468,16 +460,8 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
}
}
/*
@Override
public <I extends IsRelatedTo<Resource, Resource>> I updateIsRelatedTo(I isRelatedTo) {
// TODO Auto-generated method stub
return null;
}
*/
@Override
public <I extends IsRelatedTo<Resource, Resource>> boolean deleteIsRelatedTo(I isRelatedTo) {
public <I extends IsRelatedTo<? extends Resource, ? extends Resource>> boolean deleteIsRelatedTo(I isRelatedTo) {
try {
StringWriter stringWriter = new StringWriter();
stringWriter.append(PATH_SEPARATOR);

View File

@ -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.relation.IsIdentifiedByImpl;
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.Resource;
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.resource.EService;
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.IsRelatedTo;
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisher;
import org.gcube.informationsystem.resourceregistry.publisher.proxy.ResourceRegistryPublisherFactory;
@ -99,18 +98,21 @@ public class ResourceRegistryPublisherTest {
softwareFacet.setName("resource-registry");
softwareFacet.setVersion("1.1.0");
IsIdentifiedBy<Resource, Facet> isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(eService, softwareFacet, null);
eService.addFacet(isIdentifiedBy);
IsIdentifiedBy<EService, SoftwareFacet> isIdentifiedByESSF = new IsIdentifiedByImpl<>(eService, softwareFacet, null);
eService.addFacet(isIdentifiedByESSF);
Entities.registerSubtypes(IsIdentifiedBy.class, SoftwareFacet.class, EService.class);
logger.debug("Going to create : {}", eService);
EService createdEService = resourceRegistryPublisher.createResource(EService.class, eService);
logger.debug("Created : {}", createdEService);
SoftwareFacet createdSoftwareFacet = (SoftwareFacet) createdEService.getIdentificationFacets().get(0);
logger.debug("Created : {}", softwareFacet);
NetworkingFacet networkingFacet = new NetworkingFacetImpl();
networkingFacet.setIPAddress("146.48.87.183");
networkingFacet.setHostName("pc-frosini.isti.cnr.it");
@ -118,6 +120,7 @@ public class ResourceRegistryPublisherTest {
networkingFacet.setMask("255.255.248.0");
networkingFacet.setBroadcastAddress("146.48.87.255");
logger.debug("Going to create : {}", networkingFacet);
NetworkingFacet createdNetworkingFacet = resourceRegistryPublisher.createFacet(NetworkingFacet.class, networkingFacet);
logger.debug("Created : {}", createdNetworkingFacet);
@ -132,13 +135,17 @@ public class ResourceRegistryPublisherTest {
hostingNode.addFacet(cpuFacet);
isIdentifiedBy = new IsIdentifiedByImpl<Resource, Facet>(hostingNode, networkingFacet, null);
hostingNode.attachFacet(isIdentifiedBy);
IsIdentifiedBy<HostingNode, NetworkingFacet> isIdentifiedByHNNF = new IsIdentifiedByImpl<>(hostingNode, createdNetworkingFacet, null);
hostingNode.attachFacet(isIdentifiedByHNNF);
Hosts<HostingNode, EService> hosts = new HostsImpl<HostingNode, EService>(hostingNode, eService, null);
hostingNode.attachResource(hosts);
Entities.registerSubtypes(HostingNode.class, CPUFacet.class);
logger.debug("Going to create : {}", hostingNode);
HostingNode createdHostingNode = resourceRegistryPublisher.createResource(HostingNode.class, hostingNode);
logger.debug("Created : {}", createdHostingNode);
@ -221,8 +228,7 @@ public class ResourceRegistryPublisherTest {
logger.debug("Going to delete : {}", createdIsIdentifiedByCPUFacet);
@SuppressWarnings("unchecked")
boolean deleted = resourceRegistryPublisher.deleteConsistsOf((ConsistsOf) createdIsIdentifiedByCPUFacet);
boolean deleted = resourceRegistryPublisher.deleteConsistsOf(createdIsIdentifiedByCPUFacet);
Assert.assertTrue(deleted);
@ -232,7 +238,7 @@ public class ResourceRegistryPublisherTest {
logger.debug("Going to delete : {}", createdHosts);
deleted = resourceRegistryPublisher.deleteIsRelatedTo((IsRelatedTo) createdHosts);
deleted = resourceRegistryPublisher.deleteIsRelatedTo(createdHosts);
Assert.assertTrue(deleted);