@Test public void testShouldProcessItemTypeNotInExcludeTrackerTypeList() { context.turnOffAuthorisationSystem(); Community community = CommunityBuilder.createCommunity(context).build(); Collection collection = CollectionBuilder.createCollection(context, community).build(); Item item = ItemBuilder.createItem(context, collection).withType("Not excluded type").build(); context.restoreAuthSystemState(); ExportEventProcessor exportEventProcessor = new ItemEventProcessor(context, request, item); boolean result = exportEventProcessor.shouldProcessItemType(item); assertTrue(result); }
protected boolean shouldProcessItemType(Item item) { String trackerTypeMetadataField = configurationService.getProperty("irus.statistics.tracker.type-field"); String[] metadataValues = configurationService.getArrayProperty("irus.statistics.tracker.type-value"); List<String> trackerTypeMetadataValues; if (metadataValues.length > 0) { trackerTypeMetadataValues = new ArrayList<>(); for (String metadataValue : metadataValues) { trackerTypeMetadataValues.add(metadataValue.toLowerCase()); } } else { trackerTypeMetadataValues = null; } if (trackerTypeMetadataField != null && trackerTypeMetadataValues != null) { String[] metadataFieldSplit = trackerTypeMetadataField.split("\\."); List<MetadataValue> types = itemService .getMetadata(item, metadataFieldSplit[0], metadataFieldSplit[1], metadataFieldSplit.length == 2 ? null : metadataFieldSplit[2], Item.ANY); if (!types.isEmpty()) { for (MetadataValue type : types) { if (trackerTypeMetadataValues.contains(type.getValue().toLowerCase())) { return false; } } return true; } else { return true; } } else { return true; } }
ExportEventProcessor { protected boolean shouldProcessItemType(Item item) { String trackerTypeMetadataField = configurationService.getProperty("irus.statistics.tracker.type-field"); String[] metadataValues = configurationService.getArrayProperty("irus.statistics.tracker.type-value"); List<String> trackerTypeMetadataValues; if (metadataValues.length > 0) { trackerTypeMetadataValues = new ArrayList<>(); for (String metadataValue : metadataValues) { trackerTypeMetadataValues.add(metadataValue.toLowerCase()); } } else { trackerTypeMetadataValues = null; } if (trackerTypeMetadataField != null && trackerTypeMetadataValues != null) { String[] metadataFieldSplit = trackerTypeMetadataField.split("\\."); List<MetadataValue> types = itemService .getMetadata(item, metadataFieldSplit[0], metadataFieldSplit[1], metadataFieldSplit.length == 2 ? null : metadataFieldSplit[2], Item.ANY); if (!types.isEmpty()) { for (MetadataValue type : types) { if (trackerTypeMetadataValues.contains(type.getValue().toLowerCase())) { return false; } } return true; } else { return true; } } else { return true; } } }
ExportEventProcessor { protected boolean shouldProcessItemType(Item item) { String trackerTypeMetadataField = configurationService.getProperty("irus.statistics.tracker.type-field"); String[] metadataValues = configurationService.getArrayProperty("irus.statistics.tracker.type-value"); List<String> trackerTypeMetadataValues; if (metadataValues.length > 0) { trackerTypeMetadataValues = new ArrayList<>(); for (String metadataValue : metadataValues) { trackerTypeMetadataValues.add(metadataValue.toLowerCase()); } } else { trackerTypeMetadataValues = null; } if (trackerTypeMetadataField != null && trackerTypeMetadataValues != null) { String[] metadataFieldSplit = trackerTypeMetadataField.split("\\."); List<MetadataValue> types = itemService .getMetadata(item, metadataFieldSplit[0], metadataFieldSplit[1], metadataFieldSplit.length == 2 ? null : metadataFieldSplit[2], Item.ANY); if (!types.isEmpty()) { for (MetadataValue type : types) { if (trackerTypeMetadataValues.contains(type.getValue().toLowerCase())) { return false; } } return true; } else { return true; } } else { return true; } } ExportEventProcessor(Context context, HttpServletRequest request); }
ExportEventProcessor { protected boolean shouldProcessItemType(Item item) { String trackerTypeMetadataField = configurationService.getProperty("irus.statistics.tracker.type-field"); String[] metadataValues = configurationService.getArrayProperty("irus.statistics.tracker.type-value"); List<String> trackerTypeMetadataValues; if (metadataValues.length > 0) { trackerTypeMetadataValues = new ArrayList<>(); for (String metadataValue : metadataValues) { trackerTypeMetadataValues.add(metadataValue.toLowerCase()); } } else { trackerTypeMetadataValues = null; } if (trackerTypeMetadataField != null && trackerTypeMetadataValues != null) { String[] metadataFieldSplit = trackerTypeMetadataField.split("\\."); List<MetadataValue> types = itemService .getMetadata(item, metadataFieldSplit[0], metadataFieldSplit[1], metadataFieldSplit.length == 2 ? null : metadataFieldSplit[2], Item.ANY); if (!types.isEmpty()) { for (MetadataValue type : types) { if (trackerTypeMetadataValues.contains(type.getValue().toLowerCase())) { return false; } } return true; } else { return true; } } else { return true; } } ExportEventProcessor(Context context, HttpServletRequest request); abstract void processEvent(); }
ExportEventProcessor { protected boolean shouldProcessItemType(Item item) { String trackerTypeMetadataField = configurationService.getProperty("irus.statistics.tracker.type-field"); String[] metadataValues = configurationService.getArrayProperty("irus.statistics.tracker.type-value"); List<String> trackerTypeMetadataValues; if (metadataValues.length > 0) { trackerTypeMetadataValues = new ArrayList<>(); for (String metadataValue : metadataValues) { trackerTypeMetadataValues.add(metadataValue.toLowerCase()); } } else { trackerTypeMetadataValues = null; } if (trackerTypeMetadataField != null && trackerTypeMetadataValues != null) { String[] metadataFieldSplit = trackerTypeMetadataField.split("\\."); List<MetadataValue> types = itemService .getMetadata(item, metadataFieldSplit[0], metadataFieldSplit[1], metadataFieldSplit.length == 2 ? null : metadataFieldSplit[2], Item.ANY); if (!types.isEmpty()) { for (MetadataValue type : types) { if (trackerTypeMetadataValues.contains(type.getValue().toLowerCase())) { return false; } } return true; } else { return true; } } else { return true; } } ExportEventProcessor(Context context, HttpServletRequest request); abstract void processEvent();  }