@Override protected String getUID(ModuleType providedObject) { return providedObject.getUID(); }
@Override protected String getUID(ModuleType parsedObject) { return parsedObject.getUID(); }
public void addModuleType(ModuleType moduleType) { modulesTypes.put(moduleType.getUID(), moduleType); for (ProviderChangeListener<ModuleType> listener : listeners) { listener.added(this, moduleType); } }
public void removeModuleType(ModuleType moduleType) { removeModuleType(moduleType.getUID()); }
@Override @SuppressWarnings("unchecked") public <T extends ModuleType> T get(String moduleTypeUID, Locale locale) { Entry<Provider<ModuleType>, ModuleType> mType = getValueAndProvider(moduleTypeUID); if (mType == null) { return null; } else { ModuleType mt = locale == null ? mType.getValue() : ((ModuleTypeProvider) mType.getKey()).getModuleType(mType.getValue().getUID(), locale); return (T) createCopy(mt); } }
/** * This method is used to localize the {@link ModuleType}s. * * @param element is the {@link ModuleType} that must be localized. * @param locale represents a specific geographical, political, or cultural region. * @return the localized {@link ModuleType}. */ private ModuleType getPerLocale(ModuleType defModuleType, Locale locale) { String uid = defModuleType.getUID(); Bundle bundle = getBundle(uid); return moduleTypeI18nService.getModuleTypePerLocale(defModuleType, locale, bundle); }
/** * This method converts a {@link Collection} of {@link Rule}s, {@link Template}s or {@link ModuleType}s to a * {@link Hashtable} with keys - the UID of the object and values - the object. * * @param collection is the {@link Collection} of {@link Rule}s, {@link Template}s or {@link ModuleType}s which * must be converted. * @param list is the map with keys - the UID of the object and values - the object, which must be * filled with the objects from <tt>collection</tt>. */ @SuppressWarnings({ "rawtypes", "unchecked" }) private void addCollection(Collection collection, Map list) { if (collection != null && !collection.isEmpty()) { Iterator i = collection.iterator(); while (i.hasNext()) { Object element = i.next(); if (element instanceof ModuleType) { list.put(((ModuleType) element).getUID(), element); } if (element instanceof RuleTemplate) { list.put(((RuleTemplate) element).getUID(), element); } if (element instanceof Rule) { list.put(((Rule) element).getUID(), element); } } } }
@Override @SuppressWarnings("unchecked") public <T extends ModuleType> Collection<T> getByTags(Locale locale, String... tags) { Set<String> tagSet = tags != null ? new HashSet<String>(Arrays.asList(tags)) : null; Collection<T> result = new ArrayList<T>(20); forEach((provider, mType) -> { ModuleType mt = locale == null ? mType : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); if (tagSet == null) { result.add((T) createCopy(mt)); } else if (mt.getTags().containsAll(tagSet)) { result.add((T) createCopy(mt)); } }); return result; }
@Override public void added(ModuleType moduleType) { String moduleTypeName = moduleType.getUID(); for (ModuleHandlerFactory moduleHandlerFactory : allModuleHandlerFactories) { Collection<String> moduleTypes = moduleHandlerFactory.getTypes(); if (moduleTypes.contains(moduleTypeName)) { synchronized (this) { this.moduleHandlerFactories.put(moduleTypeName, moduleHandlerFactory); } break; } } Set<String> rules = null; synchronized (this) { Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); if (rulesPerModule != null) { rules = new HashSet<String>(); rules.addAll(rulesPerModule); } } if (rules != null) { for (String rUID : rules) { RuleStatus ruleStatus = getRuleStatus(rUID); if (ruleStatus == RuleStatus.UNINITIALIZED) { scheduleRuleInitialization(rUID); } } } }
@Override protected Set<ModuleType> importData(URL url, Parser<ModuleType> parser, InputStreamReader inputStreamReader) throws ParsingException { Set<ModuleType> providedObjects = parser.parse(inputStreamReader); if (providedObjects != null && !providedObjects.isEmpty()) { String uid = null; List<String> portfolio = new ArrayList<String>(); synchronized (providerPortfolio) { providerPortfolio.put(url, portfolio); } List<ParsingNestedException> importDataExceptions = new ArrayList<ParsingNestedException>(); for (ModuleType providedObject : providedObjects) { List<ParsingNestedException> exceptions = new ArrayList<ParsingNestedException>(); uid = providedObject.getUID(); checkExistence(uid, exceptions); if (exceptions.isEmpty()) { portfolio.add(uid); synchronized (providedObjectsHolder) { notifyListeners(providedObjectsHolder.put(uid, providedObject), providedObject); } } else { importDataExceptions.addAll(exceptions); } } if (!importDataExceptions.isEmpty()) { throw new ParsingException(importDataExceptions); } } return providedObjects; }
@Override @SuppressWarnings("unchecked") public <T extends ModuleType> Collection<T> getByTag(String moduleTypeTag, Locale locale) { Collection<T> result = new ArrayList<T>(20); forEach((provider, mType) -> { ModuleType mt = locale == null ? mType : ((ModuleTypeProvider) provider).getModuleType(mType.getUID(), locale); Collection<String> tags = mt.getTags(); if (moduleTypeTag == null) { result.add((T) createCopy(mt)); } else if (tags.contains(moduleTypeTag)) { result.add((T) createCopy(mt)); } }); return result; }
@Override public void updated(ModuleType oldElement, ModuleType moduleType) { if (moduleType.equals(oldElement)) { return; } String moduleTypeName = moduleType.getUID(); Set<String> rules = null; synchronized (this) { Set<String> rulesPerModule = mapModuleTypeToRules.get(moduleTypeName); if (rulesPerModule != null) { rules = new HashSet<String>(); rules.addAll(rulesPerModule); } } if (rules != null) { for (String rUID : rules) { final RuleStatus ruleStatus = getRuleStatus(rUID); if (ruleStatus == null) { continue; } if (ruleStatus.equals(RuleStatus.IDLE) || ruleStatus.equals(RuleStatus.RUNNING)) { unregister(getManagedRule(rUID), RuleStatusDetail.HANDLER_MISSING_ERROR, "Update Module Type " + moduleType.getUID()); setStatus(rUID, new RuleStatusInfo(RuleStatus.INITIALIZING)); } } } }
protected static void fillProperties(final ModuleType from, final ModuleTypeDTO to) { to.uid = from.getUID(); to.visibility = from.getVisibility(); to.tags = from.getTags(); to.label = from.getLabel(); to.description = from.getDescription(); to.configDescriptions = ConfigDescriptionDTOMapper.mapParameters(from.getConfigurationDescriptions()); } }
int[] columnWidths = new int[] { TABLE_WIDTH }; List<String> moduleTypeProperty = new ArrayList<String>(); moduleTypeProperty.add(moduleType.getUID()); String titleRow = Utils.getRow(columnWidths, moduleTypeProperty); columnWidths = new int[] { COLUMN_PROPERTY, COLUMN_PROPERTY_VALUE }; moduleTypeProperty.set(0, UID); moduleTypeProperty.add(moduleType.getUID()); moduleTypeContent.add(Utils.getRow(columnWidths, moduleTypeProperty)); if (moduleType.getLabel() != null) {
if (mType instanceof CompositeTriggerType) { CompositeTriggerType m = (CompositeTriggerType) mType; result = new CompositeTriggerType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getOutputs(), new ArrayList<>(m.getChildren())); result = new TriggerType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getOutputs()); result = new CompositeConditionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), new ArrayList<>(m.getChildren())); result = new ConditionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs()); result = new CompositeActionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), m.getOutputs(), new ArrayList<>(m.getChildren())); result = new ActionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), m.getOutputs()); } else {
return defModuleType; String uid = defModuleType.getUID(); String llabel = ModuleTypeI18nUtil.getLocalizedModuleTypeLabel(i18nProvider, bundle, uid, defModuleType.getLabel(), locale);