Ordering Json Properties
This commit is contained in:
parent
999603e41a
commit
5638c99feb
|
@ -396,8 +396,8 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
|
||||
objectNode.put(Element.TYPE_PROPERTY, getTypeName());
|
||||
|
||||
Collection<String> superClasses = getCachedType().getSuperTypes();
|
||||
ArrayNode arrayNode = objectMapper.valueToTree(superClasses);
|
||||
Collection<String> supertypes = getCachedType().getSuperTypes();
|
||||
ArrayNode arrayNode = objectMapper.valueToTree(supertypes);
|
||||
objectNode.replace(Element.SUPERTYPES_PROPERTY, arrayNode);
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,16 @@
|
|||
package org.gcube.informationsystem.resourceregistry.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.resourceregistry.types.CachedType;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypesCache;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyType;
|
||||
import org.gcube.informationsystem.utils.TypeUtility;
|
||||
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
|
@ -21,6 +28,25 @@ public class MetadataOrient extends ODocument implements Metadata {
|
|||
super(iClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
TypesCache typesCache = TypesCache.getInstance();
|
||||
@SuppressWarnings("unchecked")
|
||||
CachedType<PropertyType<PropertyElement>> cachedType = (CachedType<PropertyType<PropertyElement>>) typesCache.getCachedType(getTypeName());
|
||||
try {
|
||||
return cachedType.getSuperTypes();
|
||||
} catch (Exception e) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(TypeUtility.getTypeName(Property.class));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCreatedBy() {
|
||||
return this.field(Metadata.CREATED_BY_PROPERTY);
|
||||
|
@ -86,9 +112,4 @@ public class MetadataOrient extends ODocument implements Metadata {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
package org.gcube.informationsystem.resourceregistry.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.resourceregistry.types.CachedType;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypesCache;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyType;
|
||||
import org.gcube.informationsystem.utils.TypeUtility;
|
||||
|
||||
import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||
|
@ -10,7 +17,7 @@ import com.orientechnologies.orient.core.record.impl.ODocument;
|
|||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class PropagationConstraintOrient extends ODocument implements org.gcube.informationsystem.model.reference.properties.PropagationConstraint {
|
||||
public class PropagationConstraintOrient extends ODocument implements PropagationConstraint {
|
||||
|
||||
public PropagationConstraintOrient() {
|
||||
super(PropagationConstraint.NAME);
|
||||
|
@ -20,6 +27,35 @@ public class PropagationConstraintOrient extends ODocument implements org.gcube.
|
|||
super(iClassName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSupertypes() {
|
||||
TypesCache typesCache = TypesCache.getInstance();
|
||||
@SuppressWarnings("unchecked")
|
||||
CachedType<PropertyType<PropertyElement>> cachedType = (CachedType<PropertyType<PropertyElement>>) typesCache.getCachedType(getTypeName());
|
||||
try {
|
||||
return cachedType.getSuperTypes();
|
||||
} catch (Exception e) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(TypeUtility.getTypeName(Property.class));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConstraint getAddConstraint() {
|
||||
return AddConstraint.valueOf((String) this.field(PropagationConstraint.ADD_PROPERTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddConstraint(AddConstraint addConstraint) {
|
||||
this.field(PropagationConstraint.ADD_PROPERTY, addConstraint.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeleteConstraint getDeleteConstraint() {
|
||||
return DeleteConstraint.valueOf((String) this.field(PropagationConstraint.DELETE_PROPERTY));
|
||||
|
@ -40,16 +76,6 @@ public class PropagationConstraintOrient extends ODocument implements org.gcube.
|
|||
this.field(PropagationConstraint.REMOVE_PROPERTY, removeConstraint.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public AddConstraint getAddConstraint() {
|
||||
return AddConstraint.valueOf((String) this.field(PropagationConstraint.ADD_PROPERTY));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAddConstraint(AddConstraint addConstraint) {
|
||||
this.field(PropagationConstraint.ADD_PROPERTY, addConstraint.name());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getAdditionalProperties() {
|
||||
return null;
|
||||
|
@ -77,9 +103,4 @@ public class PropagationConstraintOrient extends ODocument implements org.gcube.
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeName() {
|
||||
return TypeUtility.getTypeName(this.getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue