Search in sources :

Example 61 with LinkedHashSet

use of java.util.LinkedHashSet in project opennms by OpenNMS.

the class DefaultCollectionAgentService method getSnmpInterfaceData.

/* (non-Javadoc)
     * @see org.opennms.netmgt.collectd.CollectionAgent#getSnmpInterfaceInfo(org.opennms.netmgt.collectd.IfResourceType)
     */
/**
     * <p>getSnmpInterfaceData</p>
     *
     * @return a {@link java.util.Set} object.
     */
@Override
public Set<SnmpIfData> getSnmpInterfaceData() {
    Set<OnmsSnmpInterface> snmpIfs = getSnmpInterfaces();
    Set<SnmpIfData> ifData = new LinkedHashSet<SnmpIfData>(snmpIfs.size());
    for (OnmsSnmpInterface snmpIface : snmpIfs) {
        logInitializeSnmpIf(snmpIface);
        SnmpIfData snmpIfData = new SnmpIfData(snmpIface);
        ifData.add(snmpIfData);
    //ifInfos.add(new IfInfo(type, agent, snmpIfData));
    }
    return ifData;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) OnmsSnmpInterface(org.opennms.netmgt.model.OnmsSnmpInterface)

Example 62 with LinkedHashSet

use of java.util.LinkedHashSet in project OpenAM by OpenRock.

the class PropertyXMLBuilderBase method buildSchemaTypeXML.

protected void buildSchemaTypeXML(String schemaTypeName, Set attributeSchemas, StringBuffer xml, AMModel model, ResourceBundle serviceBundle, Set readonly, boolean section, boolean addSubSection) {
    if (section) {
        String label = "lbl" + schemaTypeName.replace('.', '_');
        Object[] params = { label, schemaTypeName };
        xml.append(MessageFormat.format(SECTION_START_TAG, params));
    }
    List sorted = new ArrayList(attributeSchemas);
    if (!(attributeSchemas instanceof LinkedHashSet)) {
        // Sort attribute schemas by property key if they are not sorted by section properties.
        Collections.sort(sorted, new AttributeSchemaComparator(null));
    }
    for (Iterator iter = sorted.iterator(); iter.hasNext(); ) {
        AttributeSchema as = (AttributeSchema) iter.next();
        if (allAttributesReadonly || readonly.contains(as.getName())) {
            buildReadonlyXML(as, xml, model, serviceBundle);
        } else if (SCRIPTSELECT.equals(as.getUIType())) {
            buildScriptSelectXML(as, xml, model, serviceBundle, false);
        } else if (GLOBALSCRIPTSELECT.equals(as.getUIType())) {
            buildScriptSelectXML(as, xml, model, serviceBundle, true);
        } else {
            buildAttributeSchemaTypeXML(as, xml, model, serviceBundle, addSubSection);
            String tagClassName = getTagClassName(as);
            if (tagClassName.equals(TAGNAME_PASSWORD)) {
                buildConfirmPasswordXML(as, xml, model, serviceBundle);
            }
            if (AttributeSchema.Syntax.SCRIPT.equals(as.getSyntax())) {
                buildFileUploadXML(as, xml, model);
            }
        }
    }
    xml.append((section ? SECTION_END_TAG : ""));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) AttributeSchema(com.sun.identity.sm.AttributeSchema) ArrayList(java.util.ArrayList) List(java.util.List)

Example 63 with LinkedHashSet

use of java.util.LinkedHashSet in project OpenAM by OpenRock.

the class PropertyXMLBuilderBase method getSortedChoiceValues.

private Set getSortedChoiceValues(AttributeSchema as, Map values, ResourceBundle serviceBundle) {
    Set sorted = new TreeSet();
    if (AttributeSchema.ListOrder.INSERTION.equals(as.getListOrder())) {
        sorted = new LinkedHashSet();
    }
    Map tmp = new HashMap(2);
    tmp.put(Constants.ORGANIZATION_NAME, getCurrentRealm());
    String[] choices = as.getChoiceValues(tmp);
    if ((choices != null) && (choices.length > 0)) {
        for (int i = 0; i < choices.length; i++) {
            String val = choices[i];
            String i18nKey = as.getChoiceValueI18NKey(val);
            String localizedName = null;
            if ((i18nKey == null) || (i18nKey.trim().length() == 0)) {
                localizedName = val;
            } else {
                localizedName = com.sun.identity.shared.locale.Locale.getString(serviceBundle, i18nKey, debug);
            }
            values.put(localizedName, val);
            sorted.add(localizedName);
        }
    }
    return sorted;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) HashMap(java.util.HashMap) Map(java.util.Map)

Example 64 with LinkedHashSet

use of java.util.LinkedHashSet in project opennms by OpenNMS.

the class NrtController method getRequiredRrdGraphAttributes.

public Set<RrdGraphAttribute> getRequiredRrdGraphAttributes(OnmsResource reportResource, PrefabGraph prefabGraph) {
    Map<String, RrdGraphAttribute> available = reportResource.getRrdGraphAttributes();
    Set<RrdGraphAttribute> reqAttrs = new LinkedHashSet<RrdGraphAttribute>();
    for (String attrName : prefabGraph.getColumns()) {
        RrdGraphAttribute attr = available.get(attrName);
        if (attr != null) {
            reqAttrs.add(attr);
        }
    }
    return reqAttrs;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RrdGraphAttribute(org.opennms.netmgt.model.RrdGraphAttribute)

Example 65 with LinkedHashSet

use of java.util.LinkedHashSet in project opennms by OpenNMS.

the class DefaultThresholdsDao method fillThresholdStateMap.

private void fillThresholdStateMap(String groupName, String typeName, Map<String, Set<ThresholdEntity>> thresholdMap) {
    boolean merge = !thresholdMap.isEmpty();
    for (Basethresholddef thresh : getThresholdingConfigFactory().getThresholds(groupName)) {
        // See if map entry already exists for this datasource; if not, create a new one.
        if (thresh.getDsType().equals(typeName)) {
            try {
                BaseThresholdDefConfigWrapper wrapper = BaseThresholdDefConfigWrapper.getConfigWrapper(thresh);
                Set<ThresholdEntity> thresholdEntitySet = thresholdMap.get(wrapper.getDatasourceExpression());
                // Found set for this DS type?
                if (thresholdEntitySet == null) {
                    // Nope, create a new set
                    thresholdEntitySet = new LinkedHashSet<ThresholdEntity>();
                    thresholdMap.put(wrapper.getDatasourceExpression(), thresholdEntitySet);
                }
                try {
                    ThresholdEntity thresholdEntity = new ThresholdEntity();
                    thresholdEntity.addThreshold(wrapper);
                    if (merge) {
                        boolean updated = false;
                        for (ThresholdEntity e : thresholdEntitySet) {
                            if (thresholdEntity.getThresholdConfig().equals(e.getThresholdConfig())) {
                                e.merge(thresholdEntity);
                                updated = true;
                            }
                        }
                        if (// Does not exist!
                        !updated)
                            thresholdEntitySet.add(thresholdEntity);
                    } else {
                        thresholdEntitySet.add(thresholdEntity);
                    }
                } catch (IllegalStateException e) {
                    LOG.warn("fillThresholdStateMap: Encountered duplicate {} for datasource {}", thresh.getType(), wrapper.getDatasourceExpression(), e);
                }
            } catch (ThresholdExpressionException e) {
                LOG.warn("fillThresholdStateMap: Could not parse threshold expression", e);
            }
        }
    }
    // Search for deleted configuration
    if (merge) {
        LOG.debug("fillThresholdStateMap(merge): checking if definitions that are no longer exist for group {} using type {}", groupName, typeName);
        for (final Entry<String, Set<ThresholdEntity>> entry : thresholdMap.entrySet()) {
            final Set<ThresholdEntity> value = entry.getValue();
            for (final Iterator<ThresholdEntity> thresholdIterator = value.iterator(); thresholdIterator.hasNext(); ) {
                final ThresholdEntity entity = thresholdIterator.next();
                boolean found = false;
                for (final Basethresholddef thresh : getThresholdingConfigFactory().getThresholds(groupName)) {
                    BaseThresholdDefConfigWrapper newConfig = null;
                    try {
                        newConfig = BaseThresholdDefConfigWrapper.getConfigWrapper(thresh);
                    } catch (ThresholdExpressionException e) {
                        LOG.warn("fillThresholdStateMap: Could not parse threshold expression", e);
                    }
                    if (newConfig != null && newConfig.equals(entity.getThresholdConfig())) {
                        found = true;
                        continue;
                    }
                }
                if (!found) {
                    LOG.info("fillThresholdStateMap(merge): deleting entity {}", entity);
                    entity.delete();
                    thresholdIterator.remove();
                }
            }
        }
    }
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Basethresholddef(org.opennms.netmgt.config.threshd.Basethresholddef)

Aggregations

LinkedHashSet (java.util.LinkedHashSet)3111 ArrayList (java.util.ArrayList)632 Set (java.util.Set)410 HashSet (java.util.HashSet)334 HashMap (java.util.HashMap)312 Map (java.util.Map)284 List (java.util.List)269 File (java.io.File)266 LinkedHashMap (java.util.LinkedHashMap)257 IOException (java.io.IOException)240 Test (org.junit.Test)239 LinkedList (java.util.LinkedList)139 Collection (java.util.Collection)103 URL (java.net.URL)83 ProcessResult (org.asqatasun.entity.audit.ProcessResult)76 Iterator (java.util.Iterator)73 SourceCodeRemark (org.asqatasun.entity.audit.SourceCodeRemark)73 TreeMap (java.util.TreeMap)70 TreeSet (java.util.TreeSet)70 Collectors (java.util.stream.Collectors)69