Refs #10238: Refactor Context Port Type
Task-Url: https://support.d4science.org/issues/10238 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@158787 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
bdf17da9aa
commit
d9fe526386
|
@ -3,6 +3,7 @@ package org.gcube.informationsystem.resourceregistry.context;
|
|||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.gcube.informationsystem.model.AccessType;
|
||||
|
@ -38,10 +39,12 @@ public class ContextManagement extends EntityManagement<Context> {
|
|||
protected String name;
|
||||
|
||||
private void init() {
|
||||
forceAdmin = true;
|
||||
this.forceAdmin = true;
|
||||
|
||||
this.ignoreStartWithKeys.add(Context.PARENT_PROPERTY);
|
||||
this.ignoreStartWithKeys.add(Context.CHILDREN_PROPERTY);
|
||||
|
||||
this.erType = Context.NAME;
|
||||
}
|
||||
|
||||
public ContextManagement() {
|
||||
|
@ -338,4 +341,22 @@ public class ContextManagement extends EntityManagement<Context> {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String reallyGetAll(boolean polymorphic) throws ResourceRegistryException {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
Iterable<Vertex> iterable = orientGraph.getVerticesOfClass(erType, polymorphic);
|
||||
for(Vertex vertex : iterable){
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setElement(vertex);
|
||||
try {
|
||||
JSONObject jsonObject = contextManagement.serializeAsJson();
|
||||
jsonArray.put(jsonObject);
|
||||
}catch (ResourceRegistryException e) {
|
||||
logger.error("Unable to correctly serialize {}. It will be excluded from results. {}",
|
||||
vertex.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
return jsonArray.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -379,6 +379,17 @@ public class ContextManagementTest {
|
|||
logger.debug("The DB should be now clean");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetAll() throws Exception {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
String all = contextManagement.all(false);
|
||||
logger.debug(all);
|
||||
List<Context> contexts = ISMapper.unmarshalList(Context.class, all);
|
||||
for(Context context : contexts){
|
||||
logger.debug(ISMapper.marshal(context));
|
||||
}
|
||||
}
|
||||
|
||||
// @Test
|
||||
public void createDevContext() throws Exception {
|
||||
Context gcube = new ContextImpl("gcube");
|
||||
|
|
Loading…
Reference in New Issue