bug_24754 #12

Merged
francesco.mangiacrapa merged 7 commits from bug_24754 into master 2023-03-14 11:23:06 +01:00
1 changed files with 16 additions and 96 deletions
Showing only changes of commit 2797ae5d76 - Show all commits

View File

@ -162,91 +162,6 @@ public class ConcessioniLifeCycleManager extends Default3PhaseManager implements
return c;
}
/**
* OLD METHOD
*
* @param request
* @return
* @throws IndexingException
*/
protected Document evaluateAdditionalIndexParameters2(IndexDocumentRequest request) throws IndexingException {
Document toReturn = super.evaluateAdditionalIndexParameters(request);
if (toReturn == null)
toReturn = new Document();
Project indexingProject = request.getDocument();
// Evaluate to display project IDs
log.info("Evaluating Last ID in relationship chain. Current Concessione ID is {}", indexingProject.getId());
try {
ArrayList<Project> projects = new ArrayList<>();
ProjectAccess access = ImplementationProvider.get().getProvidedObjectByClass(ProjectAccess.class);
// get Last ID in relation chain
projects.add(indexingProject);
if (!indexingProject.getRelationshipsByName(PRECEDES).isEmpty())
scanRelation(projects, access
.getRelations(indexingProject.getProfileID(), indexingProject.getId(), PRECEDES, true).get(0),
false);
if (!indexingProject.getRelationshipsByName(FOLLOWS).isEmpty())
scanRelation(projects, access
.getRelations(indexingProject.getProfileID(), indexingProject.getId(), FOLLOWS, true).get(0),
false);
log.debug("Produced full chain [size : {}] from {}, evaluating last available for PHASE {} ",
projects.size(), indexingProject.getId(), indexingProject.getLifecycleInformation().getPhase());
List<String> toDisplayId = new ArrayList<>();
List<String> toHideIds = new ArrayList<>();
log.trace("Checking from LAST.. ");
// Projects is time -ordered so we scan from last
for (int i = projects.size() - 1; i >= 0; i--) {
Project p = projects.get(i);
log.debug("Currently checking {} : {}", p.getId(), p.getTheDocument().get("nome"));
if (!toDisplayId.isEmpty())
toHideIds.add(p.getId());
else {
// Still need to find candidate for displaying feature
// Our currently indexing project is always a good candidate
if (p.getId().equals(indexingProject.getId()))
toDisplayId.add(p.getId());
// We check PHASE in order to skip projects not yet in the PHASE we are indexing
else
switch (indexingProject.getLifecycleInformation().getPhase()) {
case Phases.PENDING_APPROVAL: {
if ((p.getLifecycleInformation().getPhase().equals(Phases.PENDING_APPROVAL)
|| p.getLifecycleInformation().getPhase().equals(Phases.PUBLISHED)))
toDisplayId.add(p.getId());
break;
}
case Phases.PUBLISHED: {
if (p.getLifecycleInformation().getPhase().equals(Phases.PUBLISHED))
toDisplayId.add(p.getId());
break;
}
}
if (!toDisplayId.isEmpty())
log.debug("Found last concessioni candidate for displaying. ID {}, PHASE {} ", toDisplayId,
p.getLifecycleInformation().getPhase());
else
toHideIds.add(p.getId()); // Still not found
}
}
toReturn.put("_toHideIds", toHideIds);
toReturn.put("_toDisplayIds", toDisplayId);
log.info("Indexing request for Concessione [ID {}] with to HIDE {} and toDisplay {} ",
indexingProject.getId(), toHideIds, toDisplayId);
return toReturn;
} catch (Exception e) {
log.error("Unable to evaluate to Hide and Display Ids ", e);
throw new IndexingException("Unable to evaluate chain ids to hide / display", e);
}
}
/**
* New method implemented by Francesco
*/
@ -299,24 +214,29 @@ public class ConcessioniLifeCycleManager extends Default3PhaseManager implements
for (int i = 0; i < projects.size(); i++) {
Project p = projects.get(i);
String phase = p.getLifecycleInformation().getPhase();
//String phase = p.getLifecycleInformation().getPhase();
// IS TO DISPLAY EMPTY? Step into only once
if (toDisplayId.isEmpty()) {
// IF PHASE IS PENDING APPROVAL OR PUBLISHED adding toDisplayId
if ((phase.equals(Phases.PENDING_APPROVAL) || phase.equals(Phases.PUBLISHED))) {
// if ((phase.equals(Phases.PENDING_APPROVAL) || phase.equals(Phases.PUBLISHED))) {
// toDisplayId.add(p.getId());
// }
toDisplayId.add(p.getId());
}
} else {
// IF PHASE IS PENDING APPROVAL OR PUBLISHED adding (the remaining) toHideIds
switch (phase) {
case Phases.PENDING_APPROVAL:
case Phases.PUBLISHED: {
toHideIds.add(p.getId());
break;
}
}
// IF PHASE IS PENDING APPROVAL OR PUBLISHED adding (the remaining) toHideIds
// switch (phase) {
// case Phases.PENDING_APPROVAL:
// case Phases.PUBLISHED: {
// toHideIds.add(p.getId());
// break;
// }
// }
}
}