Fixed bugs

This commit is contained in:
Luca Frosini 2021-02-19 15:31:26 +01:00
parent 799aa5a770
commit b7a2e6c6eb
4 changed files with 26 additions and 17 deletions

View File

@ -513,14 +513,14 @@ public abstract class ElementManagement<El extends OElement> {
element = internalCreate();
}
sanityCheck(null);
oDatabaseDocument.commit();
if(update) {
setReload(true);
}
sanityCheck(null);
// TODO Notify to subscriptionNotification
return serializeAsJsonNode().toString();
@ -556,10 +556,10 @@ public abstract class ElementManagement<El extends OElement> {
element = internalCreate();
oDatabaseDocument.commit();
sanityCheck(null);
oDatabaseDocument.commit();
// TODO Notify to subscriptionNotification
return serializeAsJsonNode().toString();
@ -621,12 +621,12 @@ public abstract class ElementManagement<El extends OElement> {
element = internalUpdate();
sanityCheck(null);
oDatabaseDocument.commit();
setReload(true);
sanityCheck(null);
// TODO Notify to subscriptionNotification
return serializeAsJsonNode().toString();

View File

@ -338,9 +338,11 @@ public class ResourceManagement extends EntityManagement<Resource> {
ResourceType resourceType = (ResourceType) cachedType.getType();
List<LinkedEntity> linkedEntities = resourceType.getFacets();
for(LinkedEntity linkedEntity : linkedEntities) {
if(linkedEntity.getMin()>0 || linkedEntity.getMax()>0) {
constraints.add(linkedEntity);
if(linkedEntities!=null) {
for(LinkedEntity linkedEntity : linkedEntities) {
if(linkedEntity.getMin()>0 || (linkedEntity.getMax()!=null && linkedEntity.getMax()>0)) {
constraints.add(linkedEntity);
}
}
}
@ -352,9 +354,11 @@ public class ResourceManagement extends EntityManagement<Resource> {
ResourceType resourceSuperType = (ResourceType) cachedSuperType.getType();
List<LinkedEntity> linkedEnt = resourceSuperType.getFacets();
for(LinkedEntity linkedEntity : linkedEnt) {
if(linkedEntity.getMin()>0 || linkedEntity.getMax()>0) {
constraints.add(linkedEntity);
if(linkedEnt!=null) {
for(LinkedEntity linkedEntity : linkedEnt) {
if(linkedEntity.getMin()>0 || (linkedEntity.getMax()!=null && linkedEntity.getMax()>0)) {
constraints.add(linkedEntity);
}
}
}
}
@ -377,6 +381,9 @@ public class ResourceManagement extends EntityManagement<Resource> {
stringBuffer.append(". Found ");
stringBuffer.append(occurrence);
stringBuffer.append(" instances");
stringBuffer.append(". The constraint has been defined by ");
stringBuffer.append(linkedEntity.getSource());
stringBuffer.append(" type.");
return stringBuffer.toString();
}
@ -415,7 +422,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
@Override
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
JsonNode resourceInstance = serializeAsJsonNode().deepCopy();
JsonNode resourceInstance = createCompleteJsonNode();
TypesCache typesCache = TypesCache.getInstance();
@ -489,8 +496,8 @@ public class ResourceManagement extends EntityManagement<Resource> {
throw new SchemaViolationException(message);
}
int max = linkedEntity.getMax();
if(max>0 && satisfiedTimes>max) {
Integer max = linkedEntity.getMax();
if((max!=null && max>0) && satisfiedTimes>max) {
String message = constraintNotSatisfiedErrorMessage(linkedEntity, satisfiedTimes);
throw new SchemaViolationException(message);
}

View File

@ -34,6 +34,7 @@ import org.gcube.informationsystem.resourceregistry.ContextTest;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
@ -167,7 +168,7 @@ public class ERManagementTest extends ContextTest {
Assert.assertTrue(deleted);
}
@Test
@Test(expected = SchemaViolationException.class)
public void testCreateRunningPlugin() throws Exception {
RunningPlugin runningPlugin = new RunningPluginImpl();

View File

@ -14,7 +14,8 @@
<logger name="org.gcube.informationsystem.types" level="INFO" />
<logger name="org.gcube.informationsystem.resourceregistry.dbinitialization" level="INFO" />
<logger name="org.gcube.informationsystem.utils.discovery" level="ERROR" />
<logger name="org.gcube.informationsystem.resourceregistry.types" level="INFO" />
<root level="WARN">
<appender-ref ref="STDOUT" />
</root>