Migrated the deleteProject. Updated the LifecycleInformationDV

This commit is contained in:
Francesco Mangiacrapa 2022-09-01 16:41:01 +02:00
parent 8c302a4110
commit b629928f36
4 changed files with 76 additions and 29 deletions

View File

@ -832,8 +832,13 @@ public class ConvertToDataValueObjectModel {
LOG.debug("toLifecycleInformationDV called for: " + li); LOG.debug("toLifecycleInformationDV called for: " + li);
LifecycleInformationDV liDV = new LifecycleInformationDV(); LifecycleInformationDV liDV = new LifecycleInformationDV();
liDV.setPhase(li.getPhase());
liDV.setErrorMessages(li.getErrorMessages()); liDV.setErrorMessages(li.getErrorMessages());
liDV.setLastInvokedStep(li.getLastInvokedStep()); liDV.setLastInvokedStep(li.getLastInvokedStep());
if(li.getLastEvent()!=null)
liDV.setLastEvent(li.getLastEvent().getEvent());
liDV.setLastOperationStatus(toLifecycleInformationDVStatus(li.getLastOperationStatus())); liDV.setLastOperationStatus(toLifecycleInformationDVStatus(li.getLastOperationStatus()));
liDV.setWarningMessages(li.getWarningMessages()); liDV.setWarningMessages(li.getWarningMessages());
liDV.setAsJSONString(toJSON(li)); liDV.setAsJSONString(toJSON(li));

View File

@ -219,7 +219,7 @@ public class ProjectsCaller {
JSONObject jObject = new JSONObject(toJSON); JSONObject jObject = new JSONObject(toJSON);
JsonPath jsonPath = JsonPath.compile("$.countByPhase[*]._id.phase"); JsonPath jsonPath = JsonPath.compile("$.countByPhase[*]._id.phase");
JSONArray phases = jsonPath.read(jObject, configuration); JSONArray phases = jsonPath.read(jObject, configuration);
HashSet<String> listdata = new HashSet<String>(phases.length()); HashSet<String> listdata = new HashSet<String>(phases.length());
for (int i = 0; i < phases.length(); i++) { for (int i = 0; i < phases.length(); i++) {
listdata.add(phases.get(i).toString()); listdata.add(phases.get(i).toString());
} }
@ -228,7 +228,7 @@ public class ProjectsCaller {
return idsPhases; return idsPhases;
} }
} }
LOG.info("getIDsPhases returning null"); LOG.info("getIDsPhases returning null");
return null; return null;
} }
@ -262,20 +262,38 @@ public class ProjectsCaller {
return phasesArr; return phasesArr;
} }
} }
LOG.info("getPhases returning null"); LOG.info("getPhases returning null");
return null; return null;
} }
/**
* Delete project.
*
* @param projectID the project ID
* @param force the force
* @throws RemoteException the remote exception
*/
public void deleteProject(String profileID, String projectID, boolean force) throws RemoteException {
LOG.info("deleteProject called for projectID {}", projectID);
Projects<Project> client = (Projects<Project>) getClient(profileID);
if (force)
client.deleteById(projectID, force);
else
client.deleteById(projectID);
return;
}
/** /**
* Query on mongo. * Query on mongo.
* *
* @param profileID the profile ID * @param profileID the profile ID
* @param totalItems the total items * @param totalItems the total items
* @param offset the offset * @param offset the offset
* @param limit the limit * @param limit the limit
* @param filter the filter * @param filter the filter
* @return the iterator * @return the iterator
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -343,7 +361,7 @@ public class ProjectsCaller {
for (ItemFieldDV itemField : orderByFields) { for (ItemFieldDV itemField : orderByFields) {
if (itemField.getJsonFields() != null) { if (itemField.getJsonFields() != null) {
for (String field : itemField.getJsonFields()) { for (String field : itemField.getJsonFields()) {
String fieldFullPath = String.format("%s.%s", itemField.getProjection(),field); String fieldFullPath = String.format("%s.%s", itemField.getProjection(), field);
orderingFields.add(fieldFullPath); orderingFields.add(fieldFullPath);
} }
} }
@ -425,19 +443,20 @@ public class ProjectsCaller {
} }
//TESTING MODE - REMOVING DIRTY DOCUMENTS //REMOVING DIRTY DOCUMENTS
/*
BasicDBObject bsValid_Document = new BasicDBObject(); BasicDBObject bsValid_Document = new BasicDBObject();
bsValid_Document.append("$exists", true); bsValid_Document.append("$exists", true);
bsValid_Document.append("$ne", null); bsValid_Document.append("$ne", null);
query.append("_theDocument", bsValid_Document); query.append("_theDocument", bsValid_Document);
BasicDBObject bsValidLfc = new BasicDBObject(); BasicDBObject bsValidLfc = new BasicDBObject();
bsValidLfc.append("$ne", null); bsValidLfc.append("$ne", null);
query.append("_lifecycleInformation._phase", bsValidLfc); query.append("_lifecycleInformation._phase", bsValidLfc);*/
BasicDBObject bsDocumentExists = new BasicDBObject(); // BasicDBObject bsDocumentExists = new BasicDBObject();
bsDocumentExists.append("$exists", false); // bsDocumentExists.append("$exists", false);
query.append("theDocument", bsDocumentExists); // query.append("theDocument", bsDocumentExists);
// BasicDBObject bsNotEqualEmpty = new BasicDBObject(); // BasicDBObject bsNotEqualEmpty = new BasicDBObject();
// bsNotEqualEmpty.append("$ne", null); // bsNotEqualEmpty.append("$ne", null);

View File

@ -19,7 +19,7 @@ public class GeoNaItemRef implements Serializable {
// this is the mongoID // this is the mongoID
private String itemId; private String itemId;
private String itemType; private String itemType; //this is the profileID
private String itemName; private String itemName;
private PublicLink restrictedLink; private PublicLink restrictedLink;

View File

@ -19,6 +19,7 @@ public class LifecycleInformationDV extends BasicLifecycleInformationDV {
private List<String> errorMessages; private List<String> errorMessages;
private List<String> warningMessages; private List<String> warningMessages;
private String asJSONString; private String asJSONString;
private String lastEvent;
/** /**
* Instantiates a new lifecycle information DV. * Instantiates a new lifecycle information DV.
@ -30,20 +31,20 @@ public class LifecycleInformationDV extends BasicLifecycleInformationDV {
/** /**
* Instantiates a new lifecycle information DV. * Instantiates a new lifecycle information DV.
* *
* @param phase the phase * @param lastInvokedStep the last invoked step
* @param lastInvokedStep the last invoked step * @param errorMessages the error messages
* @param lastOperationStatus the last operation status * @param warningMessages the warning messages
* @param errorMessages the error messages * @param asJSONString the as JSON string
* @param warningMessages the warning messages * @param lastEvent the last event
*/ */
public LifecycleInformationDV(String phase, String lastInvokedStep, Status lastOperationStatus, public LifecycleInformationDV(String lastInvokedStep, List<String> errorMessages, List<String> warningMessages,
List<String> errorMessages, List<String> warningMessages) { String asJSONString, String lastEvent) {
super(); super();
this.phase = phase;
this.lastInvokedStep = lastInvokedStep; this.lastInvokedStep = lastInvokedStep;
this.lastOperationStatus = lastOperationStatus;
this.errorMessages = errorMessages; this.errorMessages = errorMessages;
this.warningMessages = warningMessages; this.warningMessages = warningMessages;
this.asJSONString = asJSONString;
this.lastEvent = lastEvent;
} }
/** /**
@ -146,6 +147,25 @@ public class LifecycleInformationDV extends BasicLifecycleInformationDV {
} }
/**
* Sets the last event.
*
* @param lastEvent the new last event
*/
public void setLastEvent(String lastEvent) {
this.lastEvent = lastEvent;
}
/**
* Gets the last event.
*
* @return the last event
*/
public String getLastEvent() {
return lastEvent;
}
/** /**
* Gets the as JSON string. * Gets the as JSON string.
* *
@ -155,21 +175,24 @@ public class LifecycleInformationDV extends BasicLifecycleInformationDV {
return asJSONString; return asJSONString;
} }
/**
* To string.
*
* @return the string
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("LifecycleInformationDV [phase="); builder.append("LifecycleInformationDV [lastInvokedStep=");
builder.append(phase);
builder.append(", lastInvokedStep=");
builder.append(lastInvokedStep); builder.append(lastInvokedStep);
builder.append(", lastOperationStatus=");
builder.append(lastOperationStatus);
builder.append(", errorMessages="); builder.append(", errorMessages=");
builder.append(errorMessages); builder.append(errorMessages);
builder.append(", warningMessages="); builder.append(", warningMessages=");
builder.append(warningMessages); builder.append(warningMessages);
builder.append(", asJSONString="); builder.append(", asJSONString=");
builder.append(asJSONString); builder.append(asJSONString);
builder.append(", lastEvent=");
builder.append(lastEvent);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }