Fixed bugs
This commit is contained in:
parent
799aa5a770
commit
b7a2e6c6eb
|
@ -513,14 +513,14 @@ public abstract class ElementManagement<El extends OElement> {
|
||||||
element = internalCreate();
|
element = internalCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sanityCheck(null);
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
|
|
||||||
if(update) {
|
if(update) {
|
||||||
setReload(true);
|
setReload(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sanityCheck(null);
|
|
||||||
|
|
||||||
// TODO Notify to subscriptionNotification
|
// TODO Notify to subscriptionNotification
|
||||||
|
|
||||||
return serializeAsJsonNode().toString();
|
return serializeAsJsonNode().toString();
|
||||||
|
@ -556,10 +556,10 @@ public abstract class ElementManagement<El extends OElement> {
|
||||||
|
|
||||||
element = internalCreate();
|
element = internalCreate();
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
|
||||||
|
|
||||||
sanityCheck(null);
|
sanityCheck(null);
|
||||||
|
|
||||||
|
oDatabaseDocument.commit();
|
||||||
|
|
||||||
// TODO Notify to subscriptionNotification
|
// TODO Notify to subscriptionNotification
|
||||||
|
|
||||||
return serializeAsJsonNode().toString();
|
return serializeAsJsonNode().toString();
|
||||||
|
@ -621,12 +621,12 @@ public abstract class ElementManagement<El extends OElement> {
|
||||||
|
|
||||||
element = internalUpdate();
|
element = internalUpdate();
|
||||||
|
|
||||||
|
sanityCheck(null);
|
||||||
|
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
|
|
||||||
setReload(true);
|
setReload(true);
|
||||||
|
|
||||||
sanityCheck(null);
|
|
||||||
|
|
||||||
// TODO Notify to subscriptionNotification
|
// TODO Notify to subscriptionNotification
|
||||||
|
|
||||||
return serializeAsJsonNode().toString();
|
return serializeAsJsonNode().toString();
|
||||||
|
|
|
@ -338,11 +338,13 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
||||||
ResourceType resourceType = (ResourceType) cachedType.getType();
|
ResourceType resourceType = (ResourceType) cachedType.getType();
|
||||||
|
|
||||||
List<LinkedEntity> linkedEntities = resourceType.getFacets();
|
List<LinkedEntity> linkedEntities = resourceType.getFacets();
|
||||||
|
if(linkedEntities!=null) {
|
||||||
for(LinkedEntity linkedEntity : linkedEntities) {
|
for(LinkedEntity linkedEntity : linkedEntities) {
|
||||||
if(linkedEntity.getMin()>0 || linkedEntity.getMax()>0) {
|
if(linkedEntity.getMin()>0 || (linkedEntity.getMax()!=null && linkedEntity.getMax()>0)) {
|
||||||
constraints.add(linkedEntity);
|
constraints.add(linkedEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Set<CachedType> cachedSuperTypes = new HashSet<>();
|
Set<CachedType> cachedSuperTypes = new HashSet<>();
|
||||||
List<String> superTypes = cachedType.getSuperTypes();
|
List<String> superTypes = cachedType.getSuperTypes();
|
||||||
|
@ -352,12 +354,14 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
||||||
|
|
||||||
ResourceType resourceSuperType = (ResourceType) cachedSuperType.getType();
|
ResourceType resourceSuperType = (ResourceType) cachedSuperType.getType();
|
||||||
List<LinkedEntity> linkedEnt = resourceSuperType.getFacets();
|
List<LinkedEntity> linkedEnt = resourceSuperType.getFacets();
|
||||||
|
if(linkedEnt!=null) {
|
||||||
for(LinkedEntity linkedEntity : linkedEnt) {
|
for(LinkedEntity linkedEntity : linkedEnt) {
|
||||||
if(linkedEntity.getMin()>0 || linkedEntity.getMax()>0) {
|
if(linkedEntity.getMin()>0 || (linkedEntity.getMax()!=null && linkedEntity.getMax()>0)) {
|
||||||
constraints.add(linkedEntity);
|
constraints.add(linkedEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return constraints;
|
return constraints;
|
||||||
}
|
}
|
||||||
|
@ -377,6 +381,9 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
||||||
stringBuffer.append(". Found ");
|
stringBuffer.append(". Found ");
|
||||||
stringBuffer.append(occurrence);
|
stringBuffer.append(occurrence);
|
||||||
stringBuffer.append(" instances");
|
stringBuffer.append(" instances");
|
||||||
|
stringBuffer.append(". The constraint has been defined by ");
|
||||||
|
stringBuffer.append(linkedEntity.getSource());
|
||||||
|
stringBuffer.append(" type.");
|
||||||
return stringBuffer.toString();
|
return stringBuffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +422,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
|
public void sanityCheck(Map<UUID, JsonNode> expectedInstances) throws SchemaViolationException, ResourceRegistryException {
|
||||||
JsonNode resourceInstance = serializeAsJsonNode().deepCopy();
|
JsonNode resourceInstance = createCompleteJsonNode();
|
||||||
|
|
||||||
TypesCache typesCache = TypesCache.getInstance();
|
TypesCache typesCache = TypesCache.getInstance();
|
||||||
|
|
||||||
|
@ -489,8 +496,8 @@ public class ResourceManagement extends EntityManagement<Resource> {
|
||||||
throw new SchemaViolationException(message);
|
throw new SchemaViolationException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
int max = linkedEntity.getMax();
|
Integer max = linkedEntity.getMax();
|
||||||
if(max>0 && satisfiedTimes>max) {
|
if((max!=null && max>0) && satisfiedTimes>max) {
|
||||||
String message = constraintNotSatisfiedErrorMessage(linkedEntity, satisfiedTimes);
|
String message = constraintNotSatisfiedErrorMessage(linkedEntity, satisfiedTimes);
|
||||||
throw new SchemaViolationException(message);
|
throw new SchemaViolationException(message);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
|
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.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.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
|
@ -167,7 +168,7 @@ public class ERManagementTest extends ContextTest {
|
||||||
Assert.assertTrue(deleted);
|
Assert.assertTrue(deleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = SchemaViolationException.class)
|
||||||
public void testCreateRunningPlugin() throws Exception {
|
public void testCreateRunningPlugin() throws Exception {
|
||||||
RunningPlugin runningPlugin = new RunningPluginImpl();
|
RunningPlugin runningPlugin = new RunningPluginImpl();
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
<logger name="org.gcube.informationsystem.types" level="INFO" />
|
<logger name="org.gcube.informationsystem.types" level="INFO" />
|
||||||
<logger name="org.gcube.informationsystem.resourceregistry.dbinitialization" 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.utils.discovery" level="ERROR" />
|
||||||
|
<logger name="org.gcube.informationsystem.resourceregistry.types" level="INFO" />
|
||||||
|
|
||||||
<root level="WARN">
|
<root level="WARN">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
|
|
Loading…
Reference in New Issue