Catching exception on setting types as abstract because of a bug on orientdb 2.2.12
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@133565 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
a887ffaaf2
commit
a6b896ef74
4
pom.xml
4
pom.xml
|
@ -87,13 +87,13 @@
|
|||
<dependency>
|
||||
<groupId>com.orientechnologies</groupId>
|
||||
<artifactId>orientdb-graphdb</artifactId>
|
||||
<version>2.2.0</version>
|
||||
<version>2.2.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tinkerpop</groupId>
|
||||
<artifactId>frames</artifactId>
|
||||
<version>2.5.0</version>
|
||||
<version>2.6.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
|
|
@ -40,12 +40,10 @@ public class DatabaseIntializator {
|
|||
|
||||
public static boolean initGraphDB() throws Exception {
|
||||
|
||||
/*
|
||||
OLogManager.instance().setWarnEnabled(false);
|
||||
OLogManager.instance().setErrorEnabled(false);
|
||||
OLogManager.instance().setInfoEnabled(false);
|
||||
OLogManager.instance().setDebugEnabled(false);
|
||||
*/
|
||||
|
||||
logger.trace("Connecting to {} as {} to create new DB",
|
||||
DatabaseEnvironment.SERVER_URI, DatabaseEnvironment.USERNAME);
|
||||
|
@ -102,7 +100,7 @@ public class DatabaseIntializator {
|
|||
OrientEdgeType e = orientGraphNoTx.getEdgeBaseType();
|
||||
e.addSuperClass(oRestricted);
|
||||
|
||||
orientGraphNoTx.commit();
|
||||
//orientGraphNoTx.commit();
|
||||
orientGraphNoTx.shutdown();
|
||||
|
||||
factory.close();
|
||||
|
|
|
@ -54,7 +54,6 @@ public class SchemaManagementImpl implements SchemaManagement {
|
|||
OMetadata oMetadata = orientGraphNoTx.getRawGraph().getMetadata();
|
||||
OSchema oSchema = oMetadata.getSchema();
|
||||
return oSchema.getClass(entityType);
|
||||
|
||||
}
|
||||
|
||||
protected OClass getTypeSchema(String type, String baseType)
|
||||
|
@ -164,11 +163,14 @@ public class SchemaManagementImpl implements SchemaManagement {
|
|||
OrientVertexType ovt = orientGraphNoTx
|
||||
.createVertexType(typeDefinition.getName());
|
||||
ovt.setDescription(typeDefinition.getDescription());
|
||||
ovt.setAbstract(typeDefinition.isAbstractType());
|
||||
try {
|
||||
ovt.setAbstract(typeDefinition.isAbstractType());
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to set the Vertex Type {} as abstract. This is an OrientDB bug. The Type will be created as it is not abstarct.", typeDefinition.getName());
|
||||
}
|
||||
|
||||
List<OClass> oSuperclasses = getSuperclassesAndCheckCompliancy(
|
||||
orientGraphNoTx, typeDefinition, baseType.getSimpleName());
|
||||
|
||||
ovt.setSuperClasses(oSuperclasses);
|
||||
|
||||
if (Resource.class.isAssignableFrom(baseType)) {
|
||||
|
@ -218,7 +220,7 @@ public class SchemaManagementImpl implements SchemaManagement {
|
|||
}
|
||||
}
|
||||
|
||||
orientGraphNoTx.commit();
|
||||
//orientGraphNoTx.commit();
|
||||
|
||||
OClass oClass = getTypeSchema(typeDefinition.getName(), null);
|
||||
return serializeOClass(oClass);
|
||||
|
@ -250,8 +252,12 @@ public class SchemaManagementImpl implements SchemaManagement {
|
|||
OrientEdgeType oet = orientGraphNoTx.createEdgeType(typeDefinition
|
||||
.getName());
|
||||
oet.setDescription(typeDefinition.getDescription());
|
||||
oet.setAbstract(typeDefinition.isAbstractType());
|
||||
|
||||
try {
|
||||
oet.setAbstract(typeDefinition.isAbstractType());
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to set the Edge Type {} as abstract. This is an OrientDB bug. The Type will be created as it is not abstarct.", typeDefinition.getName());
|
||||
}
|
||||
|
||||
List<OClass> oSuperclasses = getSuperclassesAndCheckCompliancy(
|
||||
orientGraphNoTx, typeDefinition, baseType);
|
||||
oet.setSuperClasses(oSuperclasses);
|
||||
|
@ -291,7 +297,7 @@ public class SchemaManagementImpl implements SchemaManagement {
|
|||
}
|
||||
}
|
||||
|
||||
orientGraphNoTx.commit();
|
||||
//orientGraphNoTx.commit();
|
||||
|
||||
OClass oClass = getTypeSchema(typeDefinition.getName(), null);
|
||||
return serializeOClass(oClass);
|
||||
|
@ -369,7 +375,7 @@ public class SchemaManagementImpl implements SchemaManagement {
|
|||
}
|
||||
}
|
||||
|
||||
orientGraphNoTx.commit();
|
||||
//orientGraphNoTx.commit();
|
||||
|
||||
return serializeOClass(oClass);
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
package org.gcube.informationsystem.resourceregistry.resources.impl;
|
||||
|
||||
import org.gcube.informationsystem.model.embedded.AccessPolicy;
|
||||
import org.gcube.informationsystem.model.embedded.Header;
|
||||
import org.gcube.informationsystem.model.entity.Entity;
|
||||
import org.gcube.informationsystem.model.entity.facet.ContactFacet;
|
||||
import org.gcube.informationsystem.model.entity.resource.Actor;
|
||||
import org.gcube.informationsystem.model.relation.isrelatedto.Hosts;
|
||||
|
@ -21,10 +23,10 @@ public class SchemaManagementImplTest {
|
|||
|
||||
@Test
|
||||
public void registerEmbeddedTypeSchema() throws Exception{
|
||||
Class<?> clz = AccessPolicy.class;
|
||||
Class<?> clz = Header.class;
|
||||
String json = TypeBinder.serializeType(clz);
|
||||
logger.trace(json);
|
||||
//new SchemaManagementImpl().registerEmbeddedTypeSchema(json);
|
||||
new SchemaManagementImpl().registerEmbeddedTypeSchema(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -48,6 +50,13 @@ public class SchemaManagementImplTest {
|
|||
logger.trace(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerEntityTypeSchema() throws Exception{
|
||||
Class<?> clz = Entity.class;
|
||||
String json = TypeBinder.serializeType(clz);
|
||||
logger.trace(json);
|
||||
//new SchemaManagementImpl().registerEntitySchema(json);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void registerResourceSchema() throws Exception{
|
||||
|
|
Loading…
Reference in New Issue