@Test public void testCreateSingleQueryDSLEvent() throws InvalidParseOperationException, InvalidCreateOperationException { final HashMap<String, Object> myHashMap = new HashMap(); myHashMap.put("EventID", "all"); myHashMap.put("EventType", "all"); final JsonNode request = dslQueryHelper.createSingleQueryDSL(myHashMap); assertNotNull(request); final SelectParserSingle request2 = new SelectParserSingle(); request2.parse(request); assertEquals(result2, request2.toString()); System.out.println(request2.toString()); }
public JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap) throws InvalidParseOperationException, InvalidCreateOperationException { final fr.gouv.vitam.common.database.builder.request.single.Select select = new fr.gouv.vitam.common.database.builder.request.single.Select(); final BooleanQuery query = and(); BooleanQuery queryOr = null; for (final Entry<String, Object> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); if (ORDER_BY.equalsIgnoreCase(searchKeys)) { Map<String, String> sortSetting = (Map<String, String>) entry.getValue(); String sortField = sortSetting.get(SORT_FIELD_ENTRY); String sortType = sortSetting.get(SORT_TYPE_ENTRY); String realSortField = sortField; switch (sortField) { case AGENCY_NAME: case CONTRACT_NAME: case PROFILE_NAME: case ARCHIVE_UNIT_PROFILE_NAME: case ONTOLOGY_NAME: realSortField = "ApiField"; break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: realSortField = "Identifier"; break; default: } if (ASC_SORT_TYPE.equalsIgnoreCase(sortType)) { select.addOrderByAscFilter(realSortField); } else { select.addOrderByDescFilter(realSortField); } } else { final String searchValue = (String) entry.getValue(); switch (searchKeys) { case DEFAULT_EVENT_TYPE_PROCESS: query.add(or().add(eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS), eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS_TEST))); break; case OBJECT_IDENTIFIER_INCOME: query.add(eq("events.obIdIn", searchValue)); break; case FORMAT: query.add(exists(PUID)); break; case FORMAT_NAME: if (!searchValue.trim().isEmpty()) { query.add(match("Name", searchValue)); } break; case RULE_VALUE: if (!searchValue.trim().isEmpty()) { query.add(match(RULE_VALUE, searchValue)); } break; case ACCESSION_REGISTER: query.add(exists(ORIGINATING_AGENCY)); break; case ORIGINATING_AGENCY: query.add(eq(ORIGINATING_AGENCY, searchValue)); break; case RULES: query.add(exists(RULEVALUE)); break; case RULETYPE: if (searchValue.contains(ALL)) { break; } if (searchValue.contains(",")) { queryOr = or(); final String[] ruleTypeArray = searchValue.split(","); for (final String s : ruleTypeArray) { queryOr.add(eq("RuleType", s)); } break; } if (!searchValue.isEmpty()) { query.add(eq("RuleType", searchValue)); } break; case EVENTID: if ("all".equals(searchValue)) { query.add(exists(EVENT_ID_PROCESS)); } else { query.add(eq(EVENT_ID_PROCESS, searchValue)); } break; case EVENTTYPE: if (!searchValue.isEmpty()) { if ("all".equals(searchValue)) { query.add(exists(EVENT_TYPE_PROCESS)); } else { query.add(eq(EVENT_TYPE_PROCESS, searchValue.toUpperCase())); } } break; case DATEOPERATION: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case TRACEABILITY_OK: if ("true".equals(searchValue)) { InQuery checkStatus = in(EVENT_OUT_DETAIL, "STP_OP_SECURISATION.OK", "STP_STORAGE_SECURISATION.OK", "STP_STORAGE_SECURISATION.WARNING", "LOGBOOK_UNIT_LFC_TRACEABILITY.OK", "LOGBOOK_UNIT_LFC_TRACEABILITY.WARNING", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.OK", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.WARNING"); ExistsQuery hasFilename = exists("events.evDetData.FileName"); query .add(checkStatus) .add(hasFilename); } break; case TRACEABILITY_ID: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_FIELD_ID, searchValue)); } break; case TRACEABILITY_LOG_TYPE: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_EV_DET_DATA + '.' + TRACEABILITY_FIELD_LOG_TYPE, searchValue)); } break; case TRACEABILITY_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(TRACEABILITY_EV_DET_DATA + '.' + START_DATE, searchValue)); } break; case TRACEABILITY_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(TRACEABILITY_EV_DET_DATA + '.' + END_DATE, searchValue)); } break; case INGEST_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case INGEST_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(EVENT_DATE_TIME, searchValue)); } break; case ONTOLOGY_TYPE: if ("all".equals(searchValue)) { query.add(exists("Type")); } else if (!searchValue.isEmpty()) { query.add(match("Type", searchValue)); } case AGENCY_NAME: case CONTEXT_NAME: case CONTRACT_NAME: case PROFILE_NAME: case SCENARIO_NAME: case GRIFFIN_NAME: case ARCHIVE_UNIT_PROFILE_NAME: if ("all".equals(searchValue)) { query.add(exists("Name")); } else if (!searchValue.isEmpty()) { query.add(match("Name", searchValue)); } break; case ONTOLOGY_NAME: if ("all".equals(searchValue)) { query.add(or() .add(exists("ApiField")) .add(exists("SedaField")) ); } else if (!searchValue.isEmpty()) { query.add(or() .add(eq("ApiField", searchValue)) .add(eq("SedaField", searchValue)) ); } break; case AGENCY_ID: case CONTRACT_ID: case CONTEXT_ID: case PROFILE_ID: case SCENARIO_ID: case GRIFFIN_ID: case ARCHIVE_UNIT_PROFILE_ID: case ONTOLOGY_ID: if (!"all".equals(searchValue)) { query.add(eq("Identifier", searchValue)); } break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: if ("all".equals(searchValue)) { query.add(exists("Identifier")); } else if (!searchValue.isEmpty()) { query.add(match("Identifier", searchValue)); } break; default: if (!searchValue.isEmpty()) { query.add(eq(searchKeys, searchValue)); } } } } if (queryOr != null) { query.add(queryOr); } select.setQuery(query); LOGGER.debug("{}", select.getFinalSelect()); return select.getFinalSelect(); }
DslQueryHelper { public JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap) throws InvalidParseOperationException, InvalidCreateOperationException { final fr.gouv.vitam.common.database.builder.request.single.Select select = new fr.gouv.vitam.common.database.builder.request.single.Select(); final BooleanQuery query = and(); BooleanQuery queryOr = null; for (final Entry<String, Object> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); if (ORDER_BY.equalsIgnoreCase(searchKeys)) { Map<String, String> sortSetting = (Map<String, String>) entry.getValue(); String sortField = sortSetting.get(SORT_FIELD_ENTRY); String sortType = sortSetting.get(SORT_TYPE_ENTRY); String realSortField = sortField; switch (sortField) { case AGENCY_NAME: case CONTRACT_NAME: case PROFILE_NAME: case ARCHIVE_UNIT_PROFILE_NAME: case ONTOLOGY_NAME: realSortField = "ApiField"; break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: realSortField = "Identifier"; break; default: } if (ASC_SORT_TYPE.equalsIgnoreCase(sortType)) { select.addOrderByAscFilter(realSortField); } else { select.addOrderByDescFilter(realSortField); } } else { final String searchValue = (String) entry.getValue(); switch (searchKeys) { case DEFAULT_EVENT_TYPE_PROCESS: query.add(or().add(eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS), eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS_TEST))); break; case OBJECT_IDENTIFIER_INCOME: query.add(eq("events.obIdIn", searchValue)); break; case FORMAT: query.add(exists(PUID)); break; case FORMAT_NAME: if (!searchValue.trim().isEmpty()) { query.add(match("Name", searchValue)); } break; case RULE_VALUE: if (!searchValue.trim().isEmpty()) { query.add(match(RULE_VALUE, searchValue)); } break; case ACCESSION_REGISTER: query.add(exists(ORIGINATING_AGENCY)); break; case ORIGINATING_AGENCY: query.add(eq(ORIGINATING_AGENCY, searchValue)); break; case RULES: query.add(exists(RULEVALUE)); break; case RULETYPE: if (searchValue.contains(ALL)) { break; } if (searchValue.contains(",")) { queryOr = or(); final String[] ruleTypeArray = searchValue.split(","); for (final String s : ruleTypeArray) { queryOr.add(eq("RuleType", s)); } break; } if (!searchValue.isEmpty()) { query.add(eq("RuleType", searchValue)); } break; case EVENTID: if ("all".equals(searchValue)) { query.add(exists(EVENT_ID_PROCESS)); } else { query.add(eq(EVENT_ID_PROCESS, searchValue)); } break; case EVENTTYPE: if (!searchValue.isEmpty()) { if ("all".equals(searchValue)) { query.add(exists(EVENT_TYPE_PROCESS)); } else { query.add(eq(EVENT_TYPE_PROCESS, searchValue.toUpperCase())); } } break; case DATEOPERATION: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case TRACEABILITY_OK: if ("true".equals(searchValue)) { InQuery checkStatus = in(EVENT_OUT_DETAIL, "STP_OP_SECURISATION.OK", "STP_STORAGE_SECURISATION.OK", "STP_STORAGE_SECURISATION.WARNING", "LOGBOOK_UNIT_LFC_TRACEABILITY.OK", "LOGBOOK_UNIT_LFC_TRACEABILITY.WARNING", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.OK", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.WARNING"); ExistsQuery hasFilename = exists("events.evDetData.FileName"); query .add(checkStatus) .add(hasFilename); } break; case TRACEABILITY_ID: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_FIELD_ID, searchValue)); } break; case TRACEABILITY_LOG_TYPE: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_EV_DET_DATA + '.' + TRACEABILITY_FIELD_LOG_TYPE, searchValue)); } break; case TRACEABILITY_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(TRACEABILITY_EV_DET_DATA + '.' + START_DATE, searchValue)); } break; case TRACEABILITY_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(TRACEABILITY_EV_DET_DATA + '.' + END_DATE, searchValue)); } break; case INGEST_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case INGEST_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(EVENT_DATE_TIME, searchValue)); } break; case ONTOLOGY_TYPE: if ("all".equals(searchValue)) { query.add(exists("Type")); } else if (!searchValue.isEmpty()) { query.add(match("Type", searchValue)); } case AGENCY_NAME: case CONTEXT_NAME: case CONTRACT_NAME: case PROFILE_NAME: case SCENARIO_NAME: case GRIFFIN_NAME: case ARCHIVE_UNIT_PROFILE_NAME: if ("all".equals(searchValue)) { query.add(exists("Name")); } else if (!searchValue.isEmpty()) { query.add(match("Name", searchValue)); } break; case ONTOLOGY_NAME: if ("all".equals(searchValue)) { query.add(or() .add(exists("ApiField")) .add(exists("SedaField")) ); } else if (!searchValue.isEmpty()) { query.add(or() .add(eq("ApiField", searchValue)) .add(eq("SedaField", searchValue)) ); } break; case AGENCY_ID: case CONTRACT_ID: case CONTEXT_ID: case PROFILE_ID: case SCENARIO_ID: case GRIFFIN_ID: case ARCHIVE_UNIT_PROFILE_ID: case ONTOLOGY_ID: if (!"all".equals(searchValue)) { query.add(eq("Identifier", searchValue)); } break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: if ("all".equals(searchValue)) { query.add(exists("Identifier")); } else if (!searchValue.isEmpty()) { query.add(match("Identifier", searchValue)); } break; default: if (!searchValue.isEmpty()) { query.add(eq(searchKeys, searchValue)); } } } } if (queryOr != null) { query.add(queryOr); } select.setQuery(query); LOGGER.debug("{}", select.getFinalSelect()); return select.getFinalSelect(); } }
DslQueryHelper { public JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap) throws InvalidParseOperationException, InvalidCreateOperationException { final fr.gouv.vitam.common.database.builder.request.single.Select select = new fr.gouv.vitam.common.database.builder.request.single.Select(); final BooleanQuery query = and(); BooleanQuery queryOr = null; for (final Entry<String, Object> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); if (ORDER_BY.equalsIgnoreCase(searchKeys)) { Map<String, String> sortSetting = (Map<String, String>) entry.getValue(); String sortField = sortSetting.get(SORT_FIELD_ENTRY); String sortType = sortSetting.get(SORT_TYPE_ENTRY); String realSortField = sortField; switch (sortField) { case AGENCY_NAME: case CONTRACT_NAME: case PROFILE_NAME: case ARCHIVE_UNIT_PROFILE_NAME: case ONTOLOGY_NAME: realSortField = "ApiField"; break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: realSortField = "Identifier"; break; default: } if (ASC_SORT_TYPE.equalsIgnoreCase(sortType)) { select.addOrderByAscFilter(realSortField); } else { select.addOrderByDescFilter(realSortField); } } else { final String searchValue = (String) entry.getValue(); switch (searchKeys) { case DEFAULT_EVENT_TYPE_PROCESS: query.add(or().add(eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS), eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS_TEST))); break; case OBJECT_IDENTIFIER_INCOME: query.add(eq("events.obIdIn", searchValue)); break; case FORMAT: query.add(exists(PUID)); break; case FORMAT_NAME: if (!searchValue.trim().isEmpty()) { query.add(match("Name", searchValue)); } break; case RULE_VALUE: if (!searchValue.trim().isEmpty()) { query.add(match(RULE_VALUE, searchValue)); } break; case ACCESSION_REGISTER: query.add(exists(ORIGINATING_AGENCY)); break; case ORIGINATING_AGENCY: query.add(eq(ORIGINATING_AGENCY, searchValue)); break; case RULES: query.add(exists(RULEVALUE)); break; case RULETYPE: if (searchValue.contains(ALL)) { break; } if (searchValue.contains(",")) { queryOr = or(); final String[] ruleTypeArray = searchValue.split(","); for (final String s : ruleTypeArray) { queryOr.add(eq("RuleType", s)); } break; } if (!searchValue.isEmpty()) { query.add(eq("RuleType", searchValue)); } break; case EVENTID: if ("all".equals(searchValue)) { query.add(exists(EVENT_ID_PROCESS)); } else { query.add(eq(EVENT_ID_PROCESS, searchValue)); } break; case EVENTTYPE: if (!searchValue.isEmpty()) { if ("all".equals(searchValue)) { query.add(exists(EVENT_TYPE_PROCESS)); } else { query.add(eq(EVENT_TYPE_PROCESS, searchValue.toUpperCase())); } } break; case DATEOPERATION: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case TRACEABILITY_OK: if ("true".equals(searchValue)) { InQuery checkStatus = in(EVENT_OUT_DETAIL, "STP_OP_SECURISATION.OK", "STP_STORAGE_SECURISATION.OK", "STP_STORAGE_SECURISATION.WARNING", "LOGBOOK_UNIT_LFC_TRACEABILITY.OK", "LOGBOOK_UNIT_LFC_TRACEABILITY.WARNING", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.OK", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.WARNING"); ExistsQuery hasFilename = exists("events.evDetData.FileName"); query .add(checkStatus) .add(hasFilename); } break; case TRACEABILITY_ID: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_FIELD_ID, searchValue)); } break; case TRACEABILITY_LOG_TYPE: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_EV_DET_DATA + '.' + TRACEABILITY_FIELD_LOG_TYPE, searchValue)); } break; case TRACEABILITY_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(TRACEABILITY_EV_DET_DATA + '.' + START_DATE, searchValue)); } break; case TRACEABILITY_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(TRACEABILITY_EV_DET_DATA + '.' + END_DATE, searchValue)); } break; case INGEST_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case INGEST_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(EVENT_DATE_TIME, searchValue)); } break; case ONTOLOGY_TYPE: if ("all".equals(searchValue)) { query.add(exists("Type")); } else if (!searchValue.isEmpty()) { query.add(match("Type", searchValue)); } case AGENCY_NAME: case CONTEXT_NAME: case CONTRACT_NAME: case PROFILE_NAME: case SCENARIO_NAME: case GRIFFIN_NAME: case ARCHIVE_UNIT_PROFILE_NAME: if ("all".equals(searchValue)) { query.add(exists("Name")); } else if (!searchValue.isEmpty()) { query.add(match("Name", searchValue)); } break; case ONTOLOGY_NAME: if ("all".equals(searchValue)) { query.add(or() .add(exists("ApiField")) .add(exists("SedaField")) ); } else if (!searchValue.isEmpty()) { query.add(or() .add(eq("ApiField", searchValue)) .add(eq("SedaField", searchValue)) ); } break; case AGENCY_ID: case CONTRACT_ID: case CONTEXT_ID: case PROFILE_ID: case SCENARIO_ID: case GRIFFIN_ID: case ARCHIVE_UNIT_PROFILE_ID: case ONTOLOGY_ID: if (!"all".equals(searchValue)) { query.add(eq("Identifier", searchValue)); } break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: if ("all".equals(searchValue)) { query.add(exists("Identifier")); } else if (!searchValue.isEmpty()) { query.add(match("Identifier", searchValue)); } break; default: if (!searchValue.isEmpty()) { query.add(eq(searchKeys, searchValue)); } } } } if (queryOr != null) { query.add(queryOr); } select.setQuery(query); LOGGER.debug("{}", select.getFinalSelect()); return select.getFinalSelect(); } DslQueryHelper(); }
DslQueryHelper { public JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap) throws InvalidParseOperationException, InvalidCreateOperationException { final fr.gouv.vitam.common.database.builder.request.single.Select select = new fr.gouv.vitam.common.database.builder.request.single.Select(); final BooleanQuery query = and(); BooleanQuery queryOr = null; for (final Entry<String, Object> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); if (ORDER_BY.equalsIgnoreCase(searchKeys)) { Map<String, String> sortSetting = (Map<String, String>) entry.getValue(); String sortField = sortSetting.get(SORT_FIELD_ENTRY); String sortType = sortSetting.get(SORT_TYPE_ENTRY); String realSortField = sortField; switch (sortField) { case AGENCY_NAME: case CONTRACT_NAME: case PROFILE_NAME: case ARCHIVE_UNIT_PROFILE_NAME: case ONTOLOGY_NAME: realSortField = "ApiField"; break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: realSortField = "Identifier"; break; default: } if (ASC_SORT_TYPE.equalsIgnoreCase(sortType)) { select.addOrderByAscFilter(realSortField); } else { select.addOrderByDescFilter(realSortField); } } else { final String searchValue = (String) entry.getValue(); switch (searchKeys) { case DEFAULT_EVENT_TYPE_PROCESS: query.add(or().add(eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS), eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS_TEST))); break; case OBJECT_IDENTIFIER_INCOME: query.add(eq("events.obIdIn", searchValue)); break; case FORMAT: query.add(exists(PUID)); break; case FORMAT_NAME: if (!searchValue.trim().isEmpty()) { query.add(match("Name", searchValue)); } break; case RULE_VALUE: if (!searchValue.trim().isEmpty()) { query.add(match(RULE_VALUE, searchValue)); } break; case ACCESSION_REGISTER: query.add(exists(ORIGINATING_AGENCY)); break; case ORIGINATING_AGENCY: query.add(eq(ORIGINATING_AGENCY, searchValue)); break; case RULES: query.add(exists(RULEVALUE)); break; case RULETYPE: if (searchValue.contains(ALL)) { break; } if (searchValue.contains(",")) { queryOr = or(); final String[] ruleTypeArray = searchValue.split(","); for (final String s : ruleTypeArray) { queryOr.add(eq("RuleType", s)); } break; } if (!searchValue.isEmpty()) { query.add(eq("RuleType", searchValue)); } break; case EVENTID: if ("all".equals(searchValue)) { query.add(exists(EVENT_ID_PROCESS)); } else { query.add(eq(EVENT_ID_PROCESS, searchValue)); } break; case EVENTTYPE: if (!searchValue.isEmpty()) { if ("all".equals(searchValue)) { query.add(exists(EVENT_TYPE_PROCESS)); } else { query.add(eq(EVENT_TYPE_PROCESS, searchValue.toUpperCase())); } } break; case DATEOPERATION: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case TRACEABILITY_OK: if ("true".equals(searchValue)) { InQuery checkStatus = in(EVENT_OUT_DETAIL, "STP_OP_SECURISATION.OK", "STP_STORAGE_SECURISATION.OK", "STP_STORAGE_SECURISATION.WARNING", "LOGBOOK_UNIT_LFC_TRACEABILITY.OK", "LOGBOOK_UNIT_LFC_TRACEABILITY.WARNING", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.OK", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.WARNING"); ExistsQuery hasFilename = exists("events.evDetData.FileName"); query .add(checkStatus) .add(hasFilename); } break; case TRACEABILITY_ID: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_FIELD_ID, searchValue)); } break; case TRACEABILITY_LOG_TYPE: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_EV_DET_DATA + '.' + TRACEABILITY_FIELD_LOG_TYPE, searchValue)); } break; case TRACEABILITY_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(TRACEABILITY_EV_DET_DATA + '.' + START_DATE, searchValue)); } break; case TRACEABILITY_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(TRACEABILITY_EV_DET_DATA + '.' + END_DATE, searchValue)); } break; case INGEST_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case INGEST_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(EVENT_DATE_TIME, searchValue)); } break; case ONTOLOGY_TYPE: if ("all".equals(searchValue)) { query.add(exists("Type")); } else if (!searchValue.isEmpty()) { query.add(match("Type", searchValue)); } case AGENCY_NAME: case CONTEXT_NAME: case CONTRACT_NAME: case PROFILE_NAME: case SCENARIO_NAME: case GRIFFIN_NAME: case ARCHIVE_UNIT_PROFILE_NAME: if ("all".equals(searchValue)) { query.add(exists("Name")); } else if (!searchValue.isEmpty()) { query.add(match("Name", searchValue)); } break; case ONTOLOGY_NAME: if ("all".equals(searchValue)) { query.add(or() .add(exists("ApiField")) .add(exists("SedaField")) ); } else if (!searchValue.isEmpty()) { query.add(or() .add(eq("ApiField", searchValue)) .add(eq("SedaField", searchValue)) ); } break; case AGENCY_ID: case CONTRACT_ID: case CONTEXT_ID: case PROFILE_ID: case SCENARIO_ID: case GRIFFIN_ID: case ARCHIVE_UNIT_PROFILE_ID: case ONTOLOGY_ID: if (!"all".equals(searchValue)) { query.add(eq("Identifier", searchValue)); } break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: if ("all".equals(searchValue)) { query.add(exists("Identifier")); } else if (!searchValue.isEmpty()) { query.add(match("Identifier", searchValue)); } break; default: if (!searchValue.isEmpty()) { query.add(eq(searchKeys, searchValue)); } } } } if (queryOr != null) { query.add(queryOr); } select.setQuery(query); LOGGER.debug("{}", select.getFinalSelect()); return select.getFinalSelect(); } DslQueryHelper(); static DslQueryHelper getInstance(); JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap); JsonNode createSelectDSLQuery(Map<String, String> searchCriteriaMap); JsonNode createGetByIdDSLSelectMultipleQuery(Map<String, String> projectionCriteriaMap); JsonNode createSelectElasticsearchDSLQuery(Map<String, Object> searchCriteriaMap); JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap,
        Map<String, JsonNode> updateRules); ObjectNode createMassiveUpdateDSLBaseQuery(JsonNode modifiedFields); UpdateMultiQuery getFullMetadataActionQuery(JsonNode metadataModifications); JsonNode createSearchQueryAccessionRegister(Map<String, Object> options); JsonNode createSelectAndUpdateDSLQuery(Map<String, Object> optionsMap); }
DslQueryHelper { public JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap) throws InvalidParseOperationException, InvalidCreateOperationException { final fr.gouv.vitam.common.database.builder.request.single.Select select = new fr.gouv.vitam.common.database.builder.request.single.Select(); final BooleanQuery query = and(); BooleanQuery queryOr = null; for (final Entry<String, Object> entry : searchCriteriaMap.entrySet()) { final String searchKeys = entry.getKey(); if (ORDER_BY.equalsIgnoreCase(searchKeys)) { Map<String, String> sortSetting = (Map<String, String>) entry.getValue(); String sortField = sortSetting.get(SORT_FIELD_ENTRY); String sortType = sortSetting.get(SORT_TYPE_ENTRY); String realSortField = sortField; switch (sortField) { case AGENCY_NAME: case CONTRACT_NAME: case PROFILE_NAME: case ARCHIVE_UNIT_PROFILE_NAME: case ONTOLOGY_NAME: realSortField = "ApiField"; break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: realSortField = "Identifier"; break; default: } if (ASC_SORT_TYPE.equalsIgnoreCase(sortType)) { select.addOrderByAscFilter(realSortField); } else { select.addOrderByDescFilter(realSortField); } } else { final String searchValue = (String) entry.getValue(); switch (searchKeys) { case DEFAULT_EVENT_TYPE_PROCESS: query.add(or().add(eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS), eq(EVENT_TYPE_PROCESS, DEFAULT_EVENT_TYPE_PROCESS_TEST))); break; case OBJECT_IDENTIFIER_INCOME: query.add(eq("events.obIdIn", searchValue)); break; case FORMAT: query.add(exists(PUID)); break; case FORMAT_NAME: if (!searchValue.trim().isEmpty()) { query.add(match("Name", searchValue)); } break; case RULE_VALUE: if (!searchValue.trim().isEmpty()) { query.add(match(RULE_VALUE, searchValue)); } break; case ACCESSION_REGISTER: query.add(exists(ORIGINATING_AGENCY)); break; case ORIGINATING_AGENCY: query.add(eq(ORIGINATING_AGENCY, searchValue)); break; case RULES: query.add(exists(RULEVALUE)); break; case RULETYPE: if (searchValue.contains(ALL)) { break; } if (searchValue.contains(",")) { queryOr = or(); final String[] ruleTypeArray = searchValue.split(","); for (final String s : ruleTypeArray) { queryOr.add(eq("RuleType", s)); } break; } if (!searchValue.isEmpty()) { query.add(eq("RuleType", searchValue)); } break; case EVENTID: if ("all".equals(searchValue)) { query.add(exists(EVENT_ID_PROCESS)); } else { query.add(eq(EVENT_ID_PROCESS, searchValue)); } break; case EVENTTYPE: if (!searchValue.isEmpty()) { if ("all".equals(searchValue)) { query.add(exists(EVENT_TYPE_PROCESS)); } else { query.add(eq(EVENT_TYPE_PROCESS, searchValue.toUpperCase())); } } break; case DATEOPERATION: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case TRACEABILITY_OK: if ("true".equals(searchValue)) { InQuery checkStatus = in(EVENT_OUT_DETAIL, "STP_OP_SECURISATION.OK", "STP_STORAGE_SECURISATION.OK", "STP_STORAGE_SECURISATION.WARNING", "LOGBOOK_UNIT_LFC_TRACEABILITY.OK", "LOGBOOK_UNIT_LFC_TRACEABILITY.WARNING", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.OK", "LOGBOOK_OBJECTGROUP_LFC_TRACEABILITY.WARNING"); ExistsQuery hasFilename = exists("events.evDetData.FileName"); query .add(checkStatus) .add(hasFilename); } break; case TRACEABILITY_ID: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_FIELD_ID, searchValue)); } break; case TRACEABILITY_LOG_TYPE: if (!searchValue.isEmpty()) { query.add(eq(TRACEABILITY_EV_DET_DATA + '.' + TRACEABILITY_FIELD_LOG_TYPE, searchValue)); } break; case TRACEABILITY_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(TRACEABILITY_EV_DET_DATA + '.' + START_DATE, searchValue)); } break; case TRACEABILITY_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(TRACEABILITY_EV_DET_DATA + '.' + END_DATE, searchValue)); } break; case INGEST_START_DATE: if (!searchValue.isEmpty()) { query.add(gte(EVENT_DATE_TIME, searchValue)); } break; case INGEST_END_DATE: if (!searchValue.isEmpty()) { query.add(lte(EVENT_DATE_TIME, searchValue)); } break; case ONTOLOGY_TYPE: if ("all".equals(searchValue)) { query.add(exists("Type")); } else if (!searchValue.isEmpty()) { query.add(match("Type", searchValue)); } case AGENCY_NAME: case CONTEXT_NAME: case CONTRACT_NAME: case PROFILE_NAME: case SCENARIO_NAME: case GRIFFIN_NAME: case ARCHIVE_UNIT_PROFILE_NAME: if ("all".equals(searchValue)) { query.add(exists("Name")); } else if (!searchValue.isEmpty()) { query.add(match("Name", searchValue)); } break; case ONTOLOGY_NAME: if ("all".equals(searchValue)) { query.add(or() .add(exists("ApiField")) .add(exists("SedaField")) ); } else if (!searchValue.isEmpty()) { query.add(or() .add(eq("ApiField", searchValue)) .add(eq("SedaField", searchValue)) ); } break; case AGENCY_ID: case CONTRACT_ID: case CONTEXT_ID: case PROFILE_ID: case SCENARIO_ID: case GRIFFIN_ID: case ARCHIVE_UNIT_PROFILE_ID: case ONTOLOGY_ID: if (!"all".equals(searchValue)) { query.add(eq("Identifier", searchValue)); } break; case PROFILE_IDENTIFIER: case ARCHIVE_UNIT_PROFILE_IDENTIFIER: if ("all".equals(searchValue)) { query.add(exists("Identifier")); } else if (!searchValue.isEmpty()) { query.add(match("Identifier", searchValue)); } break; default: if (!searchValue.isEmpty()) { query.add(eq(searchKeys, searchValue)); } } } } if (queryOr != null) { query.add(queryOr); } select.setQuery(query); LOGGER.debug("{}", select.getFinalSelect()); return select.getFinalSelect(); } DslQueryHelper(); static DslQueryHelper getInstance(); JsonNode createSingleQueryDSL(Map<String, Object> searchCriteriaMap); JsonNode createSelectDSLQuery(Map<String, String> searchCriteriaMap); JsonNode createGetByIdDSLSelectMultipleQuery(Map<String, String> projectionCriteriaMap); JsonNode createSelectElasticsearchDSLQuery(Map<String, Object> searchCriteriaMap); JsonNode createUpdateByIdDSLQuery(Map<String, JsonNode> searchCriteriaMap,
        Map<String, JsonNode> updateRules); ObjectNode createMassiveUpdateDSLBaseQuery(JsonNode modifiedFields); UpdateMultiQuery getFullMetadataActionQuery(JsonNode metadataModifications); JsonNode createSearchQueryAccessionRegister(Map<String, Object> options); JsonNode createSelectAndUpdateDSLQuery(Map<String, Object> optionsMap); static final String PROJECTION_DSL; }