From 2797ae5d767d63ce0df1a5d716a57e8e3f050467 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 13 Mar 2023 16:46:32 +0100 Subject: [PATCH] ignoring phases --- .../plugins/ConcessioniLifeCycleManager.java | 112 +++--------------- 1 file changed, 16 insertions(+), 96 deletions(-) diff --git a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java index 0c01284..c83eb39 100644 --- a/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java +++ b/concessioni-lifecycle/src/main/java/org/gcube/application/cms/concessioni/plugins/ConcessioniLifeCycleManager.java @@ -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 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 toDisplayId = new ArrayList<>(); - List 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))) { - toDisplayId.add(p.getId()); - } +// if ((phase.equals(Phases.PENDING_APPROVAL) || phase.equals(Phases.PUBLISHED))) { +// toDisplayId.add(p.getId()); +// } + + toDisplayId.add(p.getId()); + } else { + + toHideIds.add(p.getId()); // 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; - } - } +// switch (phase) { +// case Phases.PENDING_APPROVAL: +// case Phases.PUBLISHED: { +// toHideIds.add(p.getId()); +// break; +// } +// } } }