Example usage for java.util EnumMap EnumMap

List of usage examples for java.util EnumMap EnumMap

Introduction

In this page you can find the example usage for java.util EnumMap EnumMap.

Prototype

public EnumMap(Map<K, ? extends V> m) 

Source Link

Document

Creates an enum map initialized from the specified map.

Usage

From source file:org.openecomp.sdc.be.servlets.AbstractValidationsServlet.java

protected void validatePayloadIsNotService(Wrapper<Response> responseWrapper, User user,
        UploadResourceInfo uploadResourceInfo, String toscaPayload) {
    log.debug("checking payload is not a tosca service");
    String heatDecodedPayload = (GeneralUtility.isBase64Encoded(toscaPayload))
            ? new String(Base64.decodeBase64(toscaPayload))
            : toscaPayload;/* w ww. ja  v a 2s .  c om*/
    Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(heatDecodedPayload);
    Either<Object, ResultStatusEnum> toscaElement = ImportUtils.findToscaElement(mappedToscaTemplate,
            ToscaTagNamesEnum.TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL);

    if (toscaElement.isLeft()) {
        ResponseFormat responseFormat = getComponentsUtils()
                .getResponseFormat(ActionStatus.NOT_RESOURCE_TOSCA_TEMPLATE);
        Response errorResponse = buildErrorResponse(responseFormat);
        EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
                AuditingFieldsKeysEnum.class);
        additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, uploadResourceInfo.getName());
        getComponentsUtils().auditResource(responseFormat, user, null, "", "",
                AuditingActionEnum.IMPORT_RESOURCE, additionalParam);
        responseWrapper.setInnerElement(errorResponse);
    }

}

From source file:gov.nih.nci.firebird.service.registration.ProtocolRegistrationServiceBean.java

private void sendRegistrationRevisionNotificationToSponsor(InvestigatorRegistration registration) {
    Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>(
            FirebirdTemplateParameter.class);
    parameterValues.put(FirebirdTemplateParameter.INVESTIGATOR_REGISTRATION, registration);
    FirebirdMessage message = getTemplateService().generateMessage(
            FirebirdMessageTemplate.REGISTRATION_REVISION_INITIATED_EMAIL_TO_SPONSOR, parameterValues);
    getEmailService().sendMessage(getSponsorEmailAddress(registration), null, null, message);
}

From source file:org.openecomp.sdc.be.servlets.AbstractValidationsServlet.java

protected void validatePayloadIsTopologyTemplate(Wrapper<Response> responseWrapper, User user,
        UploadResourceInfo uploadResourceInfo, String toscaPayload) {
    log.debug("checking payload is a tosca topology template");
    String heatDecodedPayload = (GeneralUtility.isBase64Encoded(toscaPayload))
            ? new String(Base64.decodeBase64(toscaPayload))
            : toscaPayload;//from  www .j a v  a2s. co  m
    Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(heatDecodedPayload);
    Either<Object, ResultStatusEnum> toscaElement = ImportUtils.findToscaElement(mappedToscaTemplate,
            ToscaTagNamesEnum.TOPOLOGY_TEMPLATE, ToscaElementTypeEnum.ALL);

    if (toscaElement.isRight()) {
        ResponseFormat responseFormat = getComponentsUtils()
                .getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE);
        Response errorResponse = buildErrorResponse(responseFormat);
        EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
                AuditingFieldsKeysEnum.class);
        additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, uploadResourceInfo.getName());
        getComponentsUtils().auditResource(responseFormat, user, null, "", "",
                AuditingActionEnum.IMPORT_RESOURCE, additionalParam);
        responseWrapper.setInnerElement(errorResponse);
    }

}

From source file:gov.nih.nci.firebird.service.annual.registration.AnnualRegistrationServiceBean.java

private FirebirdMessage getSponsorCompletedRegistrationEmailMessage(FirebirdUser sponsor,
        FirebirdUser coordinator, AnnualRegistration registration) {
    Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>(
            FirebirdTemplateParameter.class);
    parameterValues.put(FirebirdTemplateParameter.ANNUAL_REGISTRATION, registration);
    parameterValues.put(FirebirdTemplateParameter.FIREBIRD_LINK, generateRegistrationLink(registration));
    parameterValues.put(FirebirdTemplateParameter.SPONSOR, sponsor.getPerson());
    parameterValues.put(FirebirdTemplateParameter.REGISTRATION_COORDINATOR, coordinator.getPerson());
    return getTemplateService().generateMessage(
            FirebirdMessageTemplate.SPONSOR_COMPLETED_ANNUAL_REGISTRATION_EMAIL, parameterValues);
}

From source file:at.ac.tuwien.dsg.quelle.elasticityQuantification.engines.RequirementsMatchingEngine.java

/**
 * Does set cover to match any optional configuration. Sorts the optional
 * elements after the number of matched properties
 *
 * @param unit// w  w  w .j av a2 s  .c  o  m
 * @param requirementsToMatch
 * @return
 */
private Set<RequirementsMatchingReport<Resource>> matchOptionalResourceConfiguration(
        List<Unit> optionalConfiguration, List<Requirement> requirementsToMatch) {
    //the results will be sorted after the nr of matched stuff
    Set<RequirementsMatchingReport<Resource>> matchedReportSet = new TreeSet<RequirementsMatchingReport<Resource>>(
            new Comparator<RequirementsMatchingReport>() {
                public int compare(RequirementsMatchingReport o1, RequirementsMatchingReport o2) {
                    Integer matched1 = o1.getMatchedResourceCountForMetricType(Metric.MetricType.RESOURCE);
                    Integer matched2 = o2.getMatchedResourceCountForMetricType(Metric.MetricType.RESOURCE);
                    return -1 * matched1.compareTo(matched2); //multiplied by -1 to have the largest number first
                }
            });

    //1 go trough each optional Resource and match their requirements
    for (Unit entity : optionalConfiguration) {
        if (!(entity instanceof Resource)) {
            continue;
        } else {
            Resource resource = (Resource) entity;
            Map<Metric, MetricValue> resourceProperties = resource.getProperties();
            //match as many requirements to resource properties as possible
            List<Requirement> requirementsMatchedForThisResource = matchRequirementsToProperties(
                    resourceProperties, requirementsToMatch);
            //create the report entry 

            if (requirementsMatchedForThisResource.size() > 0) {
                Map<Metric.MetricType, List<Requirement>> matchedRequirementsMap = new EnumMap<Metric.MetricType, List<Requirement>>(
                        Metric.MetricType.class);
                matchedRequirementsMap.put(Metric.MetricType.RESOURCE, requirementsMatchedForThisResource);
                RequirementsMatchingReport<Resource> matchingReport = new RequirementsMatchingReport<Resource>(
                        matchedRequirementsMap, resource);

                //add report entry to the report
                matchedReportSet.add(matchingReport);
            }
        }
    }

    return matchedReportSet;

}

From source file:mServer.crawler.sender.MediathekArd.java

/**
 * Searches the Seite for a quality auto to get a M3U8 URL. If the URL is
 * from WRD it searches for the URLs of the MP4 files.
 *
 * @param aSeiteStringExtractor/*w w w. j av  a  2 s . c  o m*/
 *            The Seite.
 * @return A Map containing the URLs and Qualities which was found. An empty
 *         Map if nothing was found.
 */
private Map<Qualities, String> searchForUrlsWithM3U8(final MSStringBuilder aSeiteStringExtractor) {
    Map<Qualities, String> urls = new EnumMap<>(Qualities.class);

    ArrayList<String> patternMatches = new ArrayList<>();
    aSeiteStringExtractor.extractList(M3U8_PATTERN_START, M3U8_PATTERN_END, patternMatches);

    String m3u8Url = null;
    for (String patternMatch : patternMatches) {
        if (patternMatch.startsWith(TEXT_START_HTTP)) {
            m3u8Url = patternMatch;
            break;
        }
    }

    if (m3u8Url != null) {
        m3u8Url = m3u8Url.replaceAll(URL_GET_PARAMETER, "");
        if (m3u8Url.contains(M3U8Utils.M3U8_WDR_URL_BEGIN)) {
            urls.putAll(M3U8Utils.gatherUrlsFromWdrM3U8(m3u8Url));
        } else {
            urls.put(Qualities.NORMAL, m3u8Url);
        }
    }

    return urls;
}

From source file:gov.nih.nci.firebird.service.registration.ProtocolRegistrationServiceBean.java

private void sendRegistrationRevisionNotificationToInvestigator(InvestigatorRegistration registration,
        FirebirdUser coordinator) {/*ww w .ja  v  a  2  s .  c  o m*/
    Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>(
            FirebirdTemplateParameter.class);
    parameterValues.put(FirebirdTemplateParameter.REGISTRATION_COORDINATOR, coordinator.getPerson());
    parameterValues.put(FirebirdTemplateParameter.INVESTIGATOR_REGISTRATION, registration);
    FirebirdMessage message = getTemplateService().generateMessage(
            FirebirdMessageTemplate.REGISTRATION_REVISION_INITIATED_EMAIL_TO_INVESTIGATOR, parameterValues);
    getEmailService().sendMessage(registration.getProfile().getPerson().getEmail(), null, null, message);
}

From source file:org.yccheok.jstock.gui.JStockOptions.java

private Object readResolve() {
    /* For backward compatible */
    if (lastSelectedPageIndex < 0) {
        lastSelectedPageIndex = 0;/* w  w  w  .  ja va  2  s.co m*/
    }

    if (lastSelectedSellPortfolioChartIndex < 0) {
        lastSelectedSellPortfolioChartIndex = 0;
    }

    if (lastSelectedBuyPortfolioChartIndex < 0) {
        lastSelectedBuyPortfolioChartIndex = 0;
    }

    /* For backward compatible */
    if (brokingFirms == null) {
        brokingFirms = new ArrayList<>();
    }

    /* For backward compatible */
    if (country == null) {
        country = Country.UnitedState;
    } else {
        List<Country> countries = Utils.getSupportedStockMarketCountries();
        if (!countries.contains(country)) {
            country = Country.UnitedState;
        }
    }

    if (this.recentCountries == null) {
        this.recentCountries = new ArrayList<>();
    }

    Country[] countries = { Country.UnitedState, Country.Canada, Country.Malaysia, Country.UnitedKingdom,
            Country.Singapore };

    if (recentCountries.size() != DEFAULT_RECENT_COUNTRY_SIZE) {
        if (recentCountries.size() < DEFAULT_RECENT_COUNTRY_SIZE) {
            for (Country country : countries) {
                recentCountries.add(country);
            }
        }
        Set<Country> c = new HashSet<>(recentCountries);
        recentCountries = new ArrayList<>(c);
        int k = recentCountries.size();
        if (k > DEFAULT_RECENT_COUNTRY_SIZE) {
            recentCountries.subList(DEFAULT_RECENT_COUNTRY_SIZE, k).clear();
        }
    }

    if (historyDuration <= 0) {
        historyDuration = DEFAULT_HISTORY_DURATION;
    }

    if (getChatUsername() == null) {
        setChatUsername("");
    }

    if (getChatPassword() == null) {
        setChatPassword("");
    }

    if (this.getChatSystemMessageColor() == null) {
        this.setChatSystemMessageColor(DEFAULT_CHAT_SYSTEM_MESSAGE_COLOR);
    }

    if (this.getChatOwnMessageColor() == null) {
        this.setChatOwnMessageColor(DEFAULT_CHAT_OWN_MESSAGE_COLOR);
    }

    if (this.getChatOtherMessageColor() == null) {
        this.setChatOtherMessageColor(DEFAULT_CHAT_OTHER_MESSAGE_COLOR);
    }

    if (this.getFallBelowAlertForegroundColor() == null) {
        this.setFallBelowAlertForegroundColor(DEFAULT_FALL_BELOW_ALERT_FOREGROUND_COLOR);
    }

    if (this.getFallBelowAlertBackgroundColor() == null) {
        this.setFallBelowAlertBackgroundColor(DEFAULT_FALL_BELOW_ALERT_BACKGROUND_COLOR);
    }

    if (this.getRiseAboveAlertForegroundColor() == null) {
        this.setRiseAboveAlertForegroundColor(DEFAULT_RISE_ABOVE_ALERT_FOREGROUND_COLOR);
    }

    if (this.getRiseAboveAlertBackgroundColor() == null) {
        this.setRiseAboveAlertBackgroundColor(DEFAULT_RISE_ABOVE_ALERT_BACKGROUND_COLOR);
    }

    if (this.proxyAuthUserName == null) {
        this.proxyAuthUserName = "";
    }

    if (this.proxyAuthPassword == null) {
        this.proxyAuthPassword = "";
    }

    setCredentials(new NTCredentials(this.proxyAuthUserName, Utils.decrypt(this.proxyAuthPassword), "", ""));

    if (this.getLastFileIODirectory() == null) {
        this.setLastFileIODirectory("");
    }

    if (this.getLastSavedFileNameExtensionDescription() == null) {
        this.setLastFileNameExtensionDescription("CSV Documents (*.csv)");
    }

    if (this.portfolioNames == null) {
        this.portfolioNames = new EnumMap<Country, String>(Country.class);
    }

    if (this.watchlistNames == null) {
        this.watchlistNames = new EnumMap<Country, String>(Country.class);
    }

    if (this.getNewsID() == null) {
        this.setNewsID("");
    }

    if (this.yellowInformationBoxOption == null) {
        this.yellowInformationBoxOption = YellowInformationBoxOption.Follow;
    }

    if (this.stockInputSuggestionListOption == null) {
        this.stockInputSuggestionListOption = StockInputSuggestionListOption.OneColumn;
    }

    if (this.getCCEmail() == null) {
        this.setCCEmail("");
    }

    if (this.getLocale() == null) {
        this.setLocale(Locale.getDefault());
    }

    if (this.priceSources == null) {
        this.priceSources = new EnumMap<Country, PriceSource>(Country.class);
    } else {
        // Still here for xstream backward compatible. Shall be removed
        // after a while.
        if (this.priceSources.get(Country.Malaysia) == PriceSource.KLSEInfo) {
            this.priceSources.put(Country.Malaysia, PriceSource.Yahoo);
        }
    }

    if (this.currencies == null) {
        this.currencies = new EnumMap<Country, String>(Country.class);
    }

    if (this.currencyExchangeEnable == null) {
        this.currencyExchangeEnable = new EnumMap<Country, Boolean>(Country.class);
    }

    if (this.localCurrencyCountries == null) {
        this.localCurrencyCountries = new EnumMap<Country, Country>(Country.class);
    }

    //if (this.penceToPoundConversionEnabled == null) {
    //    this.penceToPoundConversionEnabled = new EnumMap<Country, Boolean>(Country.class);
    //}

    //if (false == this.penceToPoundConversionEnabled.containsKey(Country.UnitedKingdom)) {
    //    this.penceToPoundConversionEnabled.put(Country.UnitedKingdom, true);
    //}

    if (this.decimalPlaces == null) {
        this.decimalPlaces = new EnumMap<Country, DecimalPlace>(Country.class);
    }

    // Bug caused by change language menu method. We rectify it, after we 
    // fix the change language menu method.
    if (this.locale.getCountry().equals(Locale.FRANCE.getCountry())
            && this.locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) {
        this.locale = Locale.FRANCE;
    }

    if (this.chartTheme == null) {
        this.chartTheme = ChartTheme.Light;
    }

    if (this.scanningSpeed <= 1000) {
        // In previous version, it is possible for scanningSpeed <= 1000.
        // This is some how wasting CPU and network resource. Let's go green.
        this.scanningSpeed = 10000;
    }

    return this;
}

From source file:org.openecomp.sdc.be.servlets.AbstractValidationsServlet.java

protected void validateToscaTemplatePayloadName(Wrapper<Response> responseWrapper,
        UploadResourceInfo uploadResourceInfo, User user) {
    String toscaTemplatePayloadName = uploadResourceInfo.getPayloadName();
    boolean isValidSuffix = false;
    if (toscaTemplatePayloadName != null && !toscaTemplatePayloadName.isEmpty()) {
        for (String validSuffix : ImportUtils.Constants.TOSCA_YML_CSAR_VALID_SUFFIX) {
            isValidSuffix = isValidSuffix || toscaTemplatePayloadName.toLowerCase().endsWith(validSuffix);
        }/*  w  ww . j  a  v  a 2s  .  c  om*/
    }
    if (!isValidSuffix) {
        ResponseFormat responseFormat = getComponentsUtils()
                .getResponseFormat(ActionStatus.INVALID_TOSCA_FILE_EXTENSION);
        Response errorResponse = buildErrorResponse(responseFormat);
        EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>(
                AuditingFieldsKeysEnum.class);
        additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, uploadResourceInfo.getName());
        getComponentsUtils().auditResource(responseFormat, user, null, "", "",
                AuditingActionEnum.IMPORT_RESOURCE, additionalParam);
        responseWrapper.setInnerElement(errorResponse);
    }

}

From source file:gov.nih.nci.firebird.service.registration.ProtocolRegistrationServiceBean.java

private void sendRegistrationRevisionNotificationToCoordinator(InvestigatorRegistration registration,
        FirebirdUser coordinator) {//from w w  w  .j a  va 2 s.  c o  m
    Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>(
            FirebirdTemplateParameter.class);
    parameterValues.put(FirebirdTemplateParameter.INVESTIGATOR_REGISTRATION, registration);
    FirebirdMessage message = getTemplateService().generateMessage(
            FirebirdMessageTemplate.REGISTRATION_REVISION_INITIATED_EMAIL_TO_COORDINATOR, parameterValues);
    getEmailService().sendMessage(coordinator.getPerson().getEmail(), null, null, message);
}