Added createRelation method
This commit is contained in:
parent
5c644e8c1e
commit
2f263dae44
|
@ -15,6 +15,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.client.utils.Serialization;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.access.Access;
|
||||
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
|
||||
|
@ -174,7 +175,7 @@ public class ConvertToDataValueObjectModel {
|
|||
* To handler declaration DV.
|
||||
*
|
||||
* @param handlerDeclaration the handler declaration
|
||||
* @param profileName the profile name
|
||||
* @param ucd the ucd
|
||||
* @param readConfigs the read configs
|
||||
* @return the handler declaration DV
|
||||
* @throws Exception the exception
|
||||
|
@ -311,19 +312,20 @@ public class ConvertToDataValueObjectModel {
|
|||
|
||||
List<ActionDefinitionDV> listActionsDef = new ArrayList<ActionDefinitionDV>(
|
||||
jsonConfigurations.size());
|
||||
|
||||
LOG.trace("Into " + GEOPORTAL_CONFIGURATION_TYPE.actions_definition + " handlers are: {}", ucd.getHandlers());
|
||||
|
||||
LOG.trace("Into " + GEOPORTAL_CONFIGURATION_TYPE.actions_definition + " handlers are: {}",
|
||||
ucd.getHandlers());
|
||||
|
||||
List<HandlerDeclaration> listHandlersLC = ucd
|
||||
.getHandlersByType(GEOPORTAL_DATA_HANDLER.gna_concessioni_lc.getType());
|
||||
|
||||
|
||||
HandlerDeclaration handlerLC = null;
|
||||
if (listHandlersLC != null && listHandlersLC.size() > 0) {
|
||||
handlerLC = listHandlersLC.get(0);
|
||||
}
|
||||
LOG.debug("Into " + GEOPORTAL_CONFIGURATION_TYPE.actions_definition + " the handler "
|
||||
+ GEOPORTAL_DATA_HANDLER.gna_concessioni_lc + " is: {}", handlerLC);
|
||||
|
||||
|
||||
int i = 0;
|
||||
for (String asJSONString : jsonConfigurations) {
|
||||
LOG.debug(++i + ") the ActionDefinition is: " + asJSONString);
|
||||
|
@ -597,6 +599,15 @@ public class ConvertToDataValueObjectModel {
|
|||
rd.setLifecycleInfo(bld);
|
||||
}
|
||||
|
||||
if (project.getRelationships() != null) {
|
||||
List<RelationshipDV> listRelDV = new ArrayList<RelationshipDV>(project.getRelationships().size());
|
||||
for (Relationship relationship : project.getRelationships()) {
|
||||
RelationshipDV relDV = toRelationshipDV(relationship);
|
||||
listRelDV.add(relDV);
|
||||
}
|
||||
rd.setListRelationship(listRelDV);
|
||||
}
|
||||
|
||||
if (LOG.isDebugEnabled())
|
||||
LOG.debug("Returning: " + rd);
|
||||
|
||||
|
@ -962,7 +973,18 @@ public class ConvertToDataValueObjectModel {
|
|||
if (relationship == null)
|
||||
return null;
|
||||
|
||||
return new RelationshipDV(relationship.getRelationshipName(), relationship.getTargetID());
|
||||
RelationshipDV rDV = new RelationshipDV(relationship.getRelationshipName(), relationship.getTargetID());
|
||||
String jsonDocument = null;
|
||||
|
||||
try {
|
||||
jsonDocument = Serialization.asDocument(relationship).toJson();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
rDV.setAsJSON(jsonDocument);
|
||||
|
||||
return rDV;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
|||
import org.gcube.application.geoportal.common.model.configuration.Archive;
|
||||
import org.gcube.application.geoportal.common.model.configuration.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.document.Project;
|
||||
import org.gcube.application.geoportal.common.model.document.relationships.Relationship;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.QueryRequest.OrderedRequest.Direction;
|
||||
|
@ -323,6 +324,32 @@ public class ProjectsCaller {
|
|||
return client.updateDocument(projectID, updatedDocument);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the relationship.
|
||||
*
|
||||
* @param fromProfileID the from profile ID
|
||||
* @param fromProjectID the from project ID
|
||||
* @param relationshipName the relationship name
|
||||
* @param toProfileID the to profile ID
|
||||
* @param toProjectID the to project ID
|
||||
* @return the project
|
||||
* @throws RemoteException the remote exception
|
||||
*/
|
||||
public Relationship createRelationship(String fromProfileID, String fromProjectID, String relationshipName,
|
||||
String toProfileID, String toProjectID) throws RemoteException {
|
||||
LOG.info("createRelationship called for fromProfileID {} and fromProjectID {}", fromProfileID, fromProjectID);
|
||||
LOG.info("create relationshipName {}", relationshipName);
|
||||
LOG.info("to toProfileID {} and toProjectID {}", toProfileID, toProjectID);
|
||||
Projects<Project> client = (Projects<Project>) getClient(fromProfileID);
|
||||
|
||||
//TODO MISSING CREATE RELATIONSHIP
|
||||
|
||||
LOG.warn("\n\n\n\n CREATE Relationship MUST BE CALLED ON THE SERVICE \n\n\n");
|
||||
|
||||
return new Relationship(relationshipName, toProjectID, toProfileID);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Query on mongo.
|
||||
*
|
||||
|
|
|
@ -2,16 +2,19 @@ package org.gcube.application.geoportalcommon.shared.geoportal;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.BasicLifecycleInformationDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.PublicationInfoDV;
|
||||
import org.gcube.application.geoportalcommon.shared.geoportal.project.RelationshipDV;
|
||||
|
||||
public class ResultDocumentDV extends DocumentDV implements Serializable{
|
||||
public class ResultDocumentDV extends DocumentDV implements Serializable {
|
||||
|
||||
private String id;
|
||||
private String profileID;
|
||||
private BasicLifecycleInformationDV lifecycleInfo;
|
||||
private PublicationInfoDV publicationInfoDV;
|
||||
private List<RelationshipDV> listRelationshipDV;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -54,6 +57,14 @@ public class ResultDocumentDV extends DocumentDV implements Serializable{
|
|||
this.lifecycleInfo = lifecycleInfo;
|
||||
}
|
||||
|
||||
public void setListRelationship(List<RelationshipDV> listRelationshipDV) {
|
||||
this.listRelationshipDV = listRelationshipDV;
|
||||
}
|
||||
|
||||
public List<RelationshipDV> getListRelationshipDV() {
|
||||
return listRelationshipDV;
|
||||
}
|
||||
|
||||
public void setPublicationInfo(PublicationInfoDV publicationInfoDV) {
|
||||
this.publicationInfoDV = publicationInfoDV;
|
||||
|
||||
|
@ -74,6 +85,8 @@ public class ResultDocumentDV extends DocumentDV implements Serializable{
|
|||
builder.append(lifecycleInfo);
|
||||
builder.append(", publicationInfoDV=");
|
||||
builder.append(publicationInfoDV);
|
||||
builder.append(", listRelationshipDV=");
|
||||
builder.append(listRelationshipDV);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ public class RelationshipDV implements Serializable {
|
|||
private static final long serialVersionUID = 8295671124305773593L;
|
||||
private String relationshipName;
|
||||
private String targetID;
|
||||
private String asJSON;
|
||||
|
||||
public RelationshipDV() {
|
||||
|
||||
|
@ -36,6 +37,14 @@ public class RelationshipDV implements Serializable {
|
|||
this.relationshipName = relationshipName;
|
||||
}
|
||||
|
||||
public String getAsJSON() {
|
||||
return asJSON;
|
||||
}
|
||||
|
||||
public void setAsJSON(String asJSON) {
|
||||
this.asJSON = asJSON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
|
Loading…
Reference in New Issue