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);
LifecycleInformationDV liDV = new LifecycleInformationDV();
liDV.setPhase(li.getPhase());
liDV.setErrorMessages(li.getErrorMessages());
liDV.setLastInvokedStep(li.getLastInvokedStep());
if(li.getLastEvent()!=null)
liDV.setLastEvent(li.getLastEvent().getEvent());
liDV.setLastOperationStatus(toLifecycleInformationDVStatus(li.getLastOperationStatus()));
liDV.setWarningMessages(li.getWarningMessages());
liDV.setAsJSONString(toJSON(li));

View File

@ -219,7 +219,7 @@ public class ProjectsCaller {
JSONObject jObject = new JSONObject(toJSON);
JsonPath jsonPath = JsonPath.compile("$.countByPhase[*]._id.phase");
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++) {
listdata.add(phases.get(i).toString());
}
@ -228,7 +228,7 @@ public class ProjectsCaller {
return idsPhases;
}
}
LOG.info("getIDsPhases returning null");
return null;
}
@ -262,20 +262,38 @@ public class ProjectsCaller {
return phasesArr;
}
}
LOG.info("getPhases returning 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.
*
* @param profileID the profile ID
* @param profileID the profile ID
* @param totalItems the total items
* @param offset the offset
* @param limit the limit
* @param filter the filter
* @param offset the offset
* @param limit the limit
* @param filter the filter
* @return the iterator
* @throws Exception the exception
*/
@ -343,7 +361,7 @@ public class ProjectsCaller {
for (ItemFieldDV itemField : orderByFields) {
if (itemField.getJsonFields() != null) {
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);
}
}
@ -425,19 +443,20 @@ public class ProjectsCaller {
}
//TESTING MODE - REMOVING DIRTY DOCUMENTS
//REMOVING DIRTY DOCUMENTS
/*
BasicDBObject bsValid_Document = new BasicDBObject();
bsValid_Document.append("$exists", true);
bsValid_Document.append("$ne", null);
query.append("_theDocument", bsValid_Document);
BasicDBObject bsValidLfc = new BasicDBObject();
bsValidLfc.append("$ne", null);
query.append("_lifecycleInformation._phase", bsValidLfc);
query.append("_lifecycleInformation._phase", bsValidLfc);*/
BasicDBObject bsDocumentExists = new BasicDBObject();
bsDocumentExists.append("$exists", false);
query.append("theDocument", bsDocumentExists);
// BasicDBObject bsDocumentExists = new BasicDBObject();
// bsDocumentExists.append("$exists", false);
// query.append("theDocument", bsDocumentExists);
// BasicDBObject bsNotEqualEmpty = new BasicDBObject();
// bsNotEqualEmpty.append("$ne", null);

View File

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

View File

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