@Test public void reindexCollectionUnknownTest() { IndexParameters parameters = new IndexParameters(); parameters.setCollectionName("fakeName"); List<Integer> tenants = new ArrayList<>(); tenants.add(0); parameters.setTenants(tenants); metaDataImpl = new MetaDataImpl(mongoDbAccessFactory, adminManagementClientFactory, IndexationHelper.getInstance(), request, 100, 300, 100, 300, 100, 300); IndexationResult result = metaDataImpl.reindex(parameters); assertNull(result.getIndexOK()); assertNotNull(result.getIndexKO()); assertEquals(1, result.getIndexKO().size()); assertEquals("fakeName_0_*", result.getIndexKO().get(0).getIndexName()); assertEquals("Try to reindex a non metadata collection 'fakeName' with metadata module", result.getIndexKO() .get(0).getMessage()); assertEquals((Integer) 0, result.getIndexKO().get(0).getTenant()); }
public IndexationResult reindex(IndexParameters indexParam) { MetadataCollections collection; try { collection = MetadataCollections.valueOf(indexParam.getCollectionName().toUpperCase()); } catch (IllegalArgumentException exc) { String message = String.format("Try to reindex a non metadata collection '%s' with metadata module", indexParam.getCollectionName()); LOGGER.error(message); return indexationHelper.getFullKOResult(indexParam, message); } MongoCollection<Document> mongoCollection = collection.getCollection(); try (InputStream mappingStream = ElasticsearchCollections.valueOf(indexParam.getCollectionName().toUpperCase()) .getMappingAsInputStream()) { return indexationHelper.reindex(mongoCollection, collection.getName(), mongoDbAccess.getEsClient(), indexParam.getTenants(), mappingStream); } catch (IOException exc) { LOGGER.error("Cannot get '{}' elastic search mapping for tenants {}", collection.name(), indexParam.getTenants().stream().map(Object::toString).collect(Collectors.joining(", "))); return indexationHelper.getFullKOResult(indexParam, exc.getMessage()); } }
MetaDataImpl { public IndexationResult reindex(IndexParameters indexParam) { MetadataCollections collection; try { collection = MetadataCollections.valueOf(indexParam.getCollectionName().toUpperCase()); } catch (IllegalArgumentException exc) { String message = String.format("Try to reindex a non metadata collection '%s' with metadata module", indexParam.getCollectionName()); LOGGER.error(message); return indexationHelper.getFullKOResult(indexParam, message); } MongoCollection<Document> mongoCollection = collection.getCollection(); try (InputStream mappingStream = ElasticsearchCollections.valueOf(indexParam.getCollectionName().toUpperCase()) .getMappingAsInputStream()) { return indexationHelper.reindex(mongoCollection, collection.getName(), mongoDbAccess.getEsClient(), indexParam.getTenants(), mappingStream); } catch (IOException exc) { LOGGER.error("Cannot get '{}' elastic search mapping for tenants {}", collection.name(), indexParam.getTenants().stream().map(Object::toString).collect(Collectors.joining(", "))); return indexationHelper.getFullKOResult(indexParam, exc.getMessage()); } } }
MetaDataImpl { public IndexationResult reindex(IndexParameters indexParam) { MetadataCollections collection; try { collection = MetadataCollections.valueOf(indexParam.getCollectionName().toUpperCase()); } catch (IllegalArgumentException exc) { String message = String.format("Try to reindex a non metadata collection '%s' with metadata module", indexParam.getCollectionName()); LOGGER.error(message); return indexationHelper.getFullKOResult(indexParam, message); } MongoCollection<Document> mongoCollection = collection.getCollection(); try (InputStream mappingStream = ElasticsearchCollections.valueOf(indexParam.getCollectionName().toUpperCase()) .getMappingAsInputStream()) { return indexationHelper.reindex(mongoCollection, collection.getName(), mongoDbAccess.getEsClient(), indexParam.getTenants(), mappingStream); } catch (IOException exc) { LOGGER.error("Cannot get '{}' elastic search mapping for tenants {}", collection.name(), indexParam.getTenants().stream().map(Object::toString).collect(Collectors.joining(", "))); return indexationHelper.getFullKOResult(indexParam, exc.getMessage()); } } MetaDataImpl(MongoDbAccessMetadataImpl mongoDbAccess,
        int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); @VisibleForTesting  MetaDataImpl(MongoDbAccessMetadataImpl mongoDbAccess,
        AdminManagementClientFactory adminManagementClientFactory,
        IndexationHelper indexationHelper,
        DbRequest dbRequest, int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); }
MetaDataImpl { public IndexationResult reindex(IndexParameters indexParam) { MetadataCollections collection; try { collection = MetadataCollections.valueOf(indexParam.getCollectionName().toUpperCase()); } catch (IllegalArgumentException exc) { String message = String.format("Try to reindex a non metadata collection '%s' with metadata module", indexParam.getCollectionName()); LOGGER.error(message); return indexationHelper.getFullKOResult(indexParam, message); } MongoCollection<Document> mongoCollection = collection.getCollection(); try (InputStream mappingStream = ElasticsearchCollections.valueOf(indexParam.getCollectionName().toUpperCase()) .getMappingAsInputStream()) { return indexationHelper.reindex(mongoCollection, collection.getName(), mongoDbAccess.getEsClient(), indexParam.getTenants(), mappingStream); } catch (IOException exc) { LOGGER.error("Cannot get '{}' elastic search mapping for tenants {}", collection.name(), indexParam.getTenants().stream().map(Object::toString).collect(Collectors.joining(", "))); return indexationHelper.getFullKOResult(indexParam, exc.getMessage()); } } MetaDataImpl(MongoDbAccessMetadataImpl mongoDbAccess,
        int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); @VisibleForTesting  MetaDataImpl(MongoDbAccessMetadataImpl mongoDbAccess,
        AdminManagementClientFactory adminManagementClientFactory,
        IndexationHelper indexationHelper,
        DbRequest dbRequest, int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); static MetaDataImpl newMetadata(MongoDbAccessMetadataImpl mongoDbAccessMetadata,
        int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); MongoDbAccessMetadataImpl getMongoDbAccess(); void insertUnits(BulkUnitInsertRequest request); void deleteUnits(List<String> idList); void deleteObjectGroups(List<String> idList); void insertObjectGroup(JsonNode objectGroupRequest); void insertObjectGroups(List<JsonNode> objectGroupRequest); List<FacetBucket> selectOwnAccessionRegisterOnUnitByOperationId(String operationId); List<Document> createAccessionRegisterSymbolic(Integer tenant); List<ObjectGroupPerOriginatingAgency> selectOwnAccessionRegisterOnObjectGroupByOperationId(Integer tenant,
        String operationId); RequestResponse<JsonNode> selectUnitsByQuery(JsonNode selectQuery); RequestResponse<JsonNode> selectObjectGroupsByQuery(JsonNode selectQuery); RequestResponse<JsonNode> selectUnitsById(JsonNode selectQuery, String unitId); RequestResponse<JsonNode> selectObjectGroupById(JsonNode selectQuery, String objectGroupId); void updateObjectGroupId(JsonNode updateQuery, String objectId); RequestResponse<UpdateUnit> updateUnits(JsonNode updateQuery); RequestResponse<UpdateUnit> updateUnitsRules(List<String> unitIds, RuleActions ruleActions,
        Map<String, DurationData> bindRuleToDuration); UpdateUnit updateUnitById(JsonNode updateQuery, String unitId); void refreshUnit(); void refreshObjectGroup(); IndexationResult reindex(IndexParameters indexParam); void switchIndex(String alias, String newIndexName); }
MetaDataImpl { public IndexationResult reindex(IndexParameters indexParam) { MetadataCollections collection; try { collection = MetadataCollections.valueOf(indexParam.getCollectionName().toUpperCase()); } catch (IllegalArgumentException exc) { String message = String.format("Try to reindex a non metadata collection '%s' with metadata module", indexParam.getCollectionName()); LOGGER.error(message); return indexationHelper.getFullKOResult(indexParam, message); } MongoCollection<Document> mongoCollection = collection.getCollection(); try (InputStream mappingStream = ElasticsearchCollections.valueOf(indexParam.getCollectionName().toUpperCase()) .getMappingAsInputStream()) { return indexationHelper.reindex(mongoCollection, collection.getName(), mongoDbAccess.getEsClient(), indexParam.getTenants(), mappingStream); } catch (IOException exc) { LOGGER.error("Cannot get '{}' elastic search mapping for tenants {}", collection.name(), indexParam.getTenants().stream().map(Object::toString).collect(Collectors.joining(", "))); return indexationHelper.getFullKOResult(indexParam, exc.getMessage()); } } MetaDataImpl(MongoDbAccessMetadataImpl mongoDbAccess,
        int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); @VisibleForTesting  MetaDataImpl(MongoDbAccessMetadataImpl mongoDbAccess,
        AdminManagementClientFactory adminManagementClientFactory,
        IndexationHelper indexationHelper,
        DbRequest dbRequest, int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); static MetaDataImpl newMetadata(MongoDbAccessMetadataImpl mongoDbAccessMetadata,
        int ontologyCacheMaxEntries, int ontologyCacheTimeoutInSeconds,
        int archiveUnitProfileCacheMaxEntries, int archiveUnitProfileCacheTimeoutInSeconds,
        int schemaValidatorCacheMaxEntries, int schemaValidatorCacheTimeoutInSeconds); MongoDbAccessMetadataImpl getMongoDbAccess(); void insertUnits(BulkUnitInsertRequest request); void deleteUnits(List<String> idList); void deleteObjectGroups(List<String> idList); void insertObjectGroup(JsonNode objectGroupRequest); void insertObjectGroups(List<JsonNode> objectGroupRequest); List<FacetBucket> selectOwnAccessionRegisterOnUnitByOperationId(String operationId); List<Document> createAccessionRegisterSymbolic(Integer tenant); List<ObjectGroupPerOriginatingAgency> selectOwnAccessionRegisterOnObjectGroupByOperationId(Integer tenant,
        String operationId); RequestResponse<JsonNode> selectUnitsByQuery(JsonNode selectQuery); RequestResponse<JsonNode> selectObjectGroupsByQuery(JsonNode selectQuery); RequestResponse<JsonNode> selectUnitsById(JsonNode selectQuery, String unitId); RequestResponse<JsonNode> selectObjectGroupById(JsonNode selectQuery, String objectGroupId); void updateObjectGroupId(JsonNode updateQuery, String objectId); RequestResponse<UpdateUnit> updateUnits(JsonNode updateQuery); RequestResponse<UpdateUnit> updateUnitsRules(List<String> unitIds, RuleActions ruleActions,
        Map<String, DurationData> bindRuleToDuration); UpdateUnit updateUnitById(JsonNode updateQuery, String unitId); void refreshUnit(); void refreshObjectGroup(); IndexationResult reindex(IndexParameters indexParam); void switchIndex(String alias, String newIndexName);  }