List of usage examples for java.util EnumMap EnumMap
public EnumMap(Map<K, ? extends V> m)
From source file:org.openecomp.sdc.be.servlets.AbstractValidationsServlet.java
protected void validatePayloadNameSpace(Wrapper<Response> responseWrapper, UploadResourceInfo resourceInfo, User user, String toscaPayload) { boolean isValid; String nameSpace = ""; String heatDecodedPayload = (GeneralUtility.isBase64Encoded(toscaPayload)) ? new String(Base64.decodeBase64(toscaPayload)) : toscaPayload;//from www . j av a 2 s .c o m Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(heatDecodedPayload); Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils .findFirstToscaMapElement(mappedToscaTemplate, ToscaTagNamesEnum.NODE_TYPES); if (toscaElement.isRight() || toscaElement.left().value().size() != 1) { isValid = false; } else { nameSpace = toscaElement.left().value().keySet().iterator().next(); isValid = nameSpace.startsWith(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX); } if (!isValid) { ResponseFormat responseFormat = getComponentsUtils() .getResponseFormat(ActionStatus.INVALID_RESOURCE_NAMESPACE); Response errorResponse = buildErrorResponse(responseFormat); EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>( AuditingFieldsKeysEnum.class); additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceInfo.getName()); getComponentsUtils().auditResource(responseFormat, user, null, "", "", AuditingActionEnum.IMPORT_RESOURCE, additionalParam); responseWrapper.setInnerElement(errorResponse); } else { String str1 = nameSpace.substring(Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX.length()); String[] findTypes = str1.split("\\."); if (ResourceTypeEnum.contains(findTypes[0].toUpperCase())) { String type = findTypes[0].toUpperCase(); resourceInfo.setResourceType(type); } else { resourceInfo.setResourceType(ResourceTypeEnum.VFC.name()); } } }
From source file:gov.nih.nci.firebird.service.registration.ProtocolRegistrationServiceBean.java
private FirebirdMessage getInvitationEmailMessage(InvestigatorRegistration registration) { Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>( FirebirdTemplateParameter.class); parameterValues.put(FirebirdTemplateParameter.INVESTIGATOR_REGISTRATION, registration); parameterValues.put(FirebirdTemplateParameter.FIREBIRD_LINK, FirebirdConstants.FIREBIRD_HOME_URL_PATH); parameterValues.put(FirebirdTemplateParameter.SPONSOR_EMAIL_ADDRESS, getSponsorEmailAddress(registration)); return getTemplateService().generateMessage(FirebirdMessageTemplate.INVESTIGATOR_INVITATION_EMAIL, parameterValues);// w w w . jav a2s. c o m }
From source file:org.codehaus.mojo.license.AbstractFileHeaderMojo.java
/** * {@inheritDoc}/*from ww w . j a va 2 s .c om*/ */ @Override public void doAction() throws Exception { long t0 = System.nanoTime(); clear(); processedFiles = new HashSet<File>(); result = new EnumMap<FileState, Set<File>>(FileState.class); try { for (Map.Entry<String, List<File>> commentStyleFiles : filesToTreateByCommentStyle.entrySet()) { String commentStyle = commentStyleFiles.getKey(); List<File> files = commentStyleFiles.getValue(); processCommentStyle(commentStyle, files); } } finally { checkResults(result); int nbFiles = processedFiles.size(); if (nbFiles == 0) { getLog().warn("No file to scan."); } else { String delay = MojoHelper.convertTime(System.nanoTime() - t0); String message = String.format("Scan %s file%s header done in %s.", nbFiles, nbFiles > 1 ? "s" : "", delay); getLog().info(message); } Set<FileState> states = result.keySet(); if (states.size() == 1 && states.contains(FileState.uptodate)) { // all files where up to date getLog().info("All files are up-to-date."); } else { StringBuilder buffer = new StringBuilder(); for (FileState state : FileState.values()) { reportType(state, buffer); } getLog().info(buffer.toString()); } // clean internal states if (clearAfterOperation) { clear(); } } }
From source file:gov.nih.nci.firebird.service.annual.registration.AnnualRegistrationServiceBean.java
private FirebirdMessage createRenewalReminderEmailToInvestigator(AnnualRegistration registration) { Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>( FirebirdTemplateParameter.class); parameterValues.put(FirebirdTemplateParameter.FIREBIRD_LINK, generateRegistrationLink(registration)); return getTemplateService().generateMessage( FirebirdMessageTemplate.ANNUAL_REGISTRATION_RENEWAL_THIRTY_DAY_NOTICE_EMAIL_TO_INVESTIGATOR, parameterValues);/* ww w. j ava2s .c o m*/ }
From source file:gov.nih.nci.firebird.service.registration.ProtocolRegistrationServiceBean.java
private FirebirdMessage getInvitationEmailMessage(SubInvestigatorRegistration registration) { Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>( FirebirdTemplateParameter.class); parameterValues.put(FirebirdTemplateParameter.SUBINVESTIGATOR_REGISTRATION, registration); parameterValues.put(FirebirdTemplateParameter.FIREBIRD_LINK, FirebirdConstants.FIREBIRD_HOME_URL_PATH); parameterValues.put(FirebirdTemplateParameter.SPONSOR_EMAIL_ADDRESS, getSponsorEmailAddress(registration)); return getTemplateService().generateMessage(FirebirdMessageTemplate.SUBINVESTIGATOR_INVITATION_EMAIL, parameterValues);//from www .j a va 2 s . c o m }
From source file:org.structr.core.entity.SchemaNode.java
@Override public String getAuxiliarySource() throws FrameworkException { // only File needs to return auxiliary code! if (!"File".equals(getClassName())) { return null; }/* w ww . j a v a2 s . c om*/ final Map<Actions.Type, List<ActionEntry>> saveActions = new EnumMap<>(Actions.Type.class); final Map<String, Set<String>> viewProperties = new LinkedHashMap<>(); final Set<String> propertyNames = new LinkedHashSet<>(); final Set<Validator> validators = new LinkedHashSet<>(); final Set<String> enums = new LinkedHashSet<>(); final String _className = getProperty(name); final ErrorBuffer dummyErrorBuffer = new ErrorBuffer(); // extract properties final String propertyDefinitions = SchemaHelper.extractProperties(this, propertyNames, validators, enums, viewProperties, dummyErrorBuffer); final String viewDefinitions = SchemaHelper.extractViews(this, viewProperties, dummyErrorBuffer); final String methodDefinitions = SchemaHelper.extractMethods(this, saveActions); if (!propertyNames.isEmpty() || !viewProperties.isEmpty() || validators.isEmpty() || !saveActions.isEmpty()) { final StringBuilder src = new StringBuilder(); src.append("package org.structr.dynamic;\n\n"); SchemaHelper.formatImportStatements(this, src, AbstractNode.class); src.append("public class _").append(_className).append("Helper {\n"); // output possible enum definitions for (final String enumDefition : enums) { src.append(enumDefition); } // formatting is important :) if (!enums.isEmpty()) { src.append("\n"); } if (!propertyNames.isEmpty()) { src.append("\n"); src.append(propertyDefinitions); src.append(viewDefinitions); src.append(methodDefinitions); src.append("\n\tstatic {\n\n"); for (final String name : propertyNames) { final String propertyName = name + "Property"; src.append("\t\t").append(propertyName).append(".setDeclaringClass(").append(_className) .append(".class);\n\n"); src.append("\t\tStructrApp.getConfiguration().registerDynamicProperty(").append(_className) .append(".class, ").append(propertyName).append(");\n"); src.append("\t\tStructrApp.getConfiguration().registerPropertySet(").append(_className) .append(".class, PropertyView.Ui, ").append(propertyName).append(");\n\n"); } // Code for custom Views on "File" type for (final String viewName : viewProperties.keySet()) { for (String propertyName : viewProperties.get(viewName)) { if (propertyName.endsWith("Property")) { propertyName = propertyName.substring(0, propertyName.length() - 8); } src.append("\t\tStructrApp.getConfiguration().registerPropertySet(").append(_className) .append(".class, \"").append(viewName).append("\", \"").append(propertyName) .append("\");\n\n"); } } src.append("\t}\n\n"); } SchemaHelper.formatDynamicValidators(src, validators); SchemaHelper.formatDynamicSaveActions(src, saveActions); src.append("}\n"); return src.toString(); } return null; }
From source file:gov.nih.nci.firebird.service.annual.registration.AnnualRegistrationServiceBean.java
private FirebirdMessage createRenewalReminderEmailToCoordinator(AnnualRegistration registration) { Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>( FirebirdTemplateParameter.class); parameterValues.put(FirebirdTemplateParameter.FIREBIRD_LINK, generateRegistrationLink(registration)); parameterValues.put(FirebirdTemplateParameter.ANNUAL_REGISTRATION, registration); return getTemplateService().generateMessage( FirebirdMessageTemplate.ANNUAL_REGISTRATION_RENEWAL_THIRTY_DAY_NOTICE_EMAIL_TO_COORDINATOR, parameterValues);/*ww w. ja v a 2 s . c om*/ }
From source file:org.safecreative.api.wrapper.SafeCreativeAPIWrapper.java
/** * Get a map of the license features./*from w w w .j a va 2 s . co m*/ * * @return Map of license features. * @throws ApiException */ @SuppressWarnings("unchecked") public EnumMap<License.Feature, LicenseFeatureObject> getLicenseFeatures() throws ApiException { setApiUrl(); String result = callComponent("license.features"); XStream xs = createXStream(); // alias for license features xs.registerConverter(new LicenseFeatureConverter()); List<LicenseFeatureObject> features = readList(result, "features", "feature", LicenseFeatureObject.class, xs); log.debug("License features {}", features); // generate map EnumMap<License.Feature, LicenseFeatureObject> featuresMap = new EnumMap<License.Feature, LicenseFeatureObject>( License.Feature.class); for (LicenseFeatureObject feature : features) { featuresMap.put(feature.getFeature(), feature); } return featuresMap; }
From source file:org.openecomp.sdc.be.servlets.AbstractValidationsServlet.java
protected void validatePayloadIsSingleResource(Wrapper<Response> responseWrapper, UploadResourceInfo uploadResourceInfo, User user, String toscaPayload) { log.debug("checking payload contains single resource"); boolean isValid; String heatDecodedPayload = (GeneralUtility.isBase64Encoded(toscaPayload)) ? new String(Base64.decodeBase64(toscaPayload)) : toscaPayload;//from ww w . j av a 2s.co m Map<String, Object> mappedToscaTemplate = (Map<String, Object>) new Yaml().load(heatDecodedPayload); Either<Map<String, Object>, ResultStatusEnum> toscaElement = ImportUtils .findFirstToscaMapElement(mappedToscaTemplate, ToscaTagNamesEnum.NODE_TYPES); if (toscaElement.isRight()) { isValid = false; } else { isValid = toscaElement.left().value().size() == 1; } if (!isValid) { ResponseFormat responseFormat = getComponentsUtils() .getResponseFormat(ActionStatus.NOT_SINGLE_RESOURCE); 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.AnnualRegistrationServiceBeanTest.java
@Test public void testGetCoordinatorCompletedRegistrationEmailMessage() { FirebirdUser coordinator = FirebirdUserFactory.getInstance().create(); AnnualRegistration registration = AnnualRegistrationFactory.getInstance().create(); bean.getCoordinatorCompletedRegistrationEmailMessage(coordinator, registration); Map<FirebirdTemplateParameter, Object> parameterValues = new EnumMap<FirebirdTemplateParameter, Object>( FirebirdTemplateParameter.class); parameterValues.put(FirebirdTemplateParameter.ANNUAL_REGISTRATION, registration); parameterValues.put(FirebirdTemplateParameter.FIREBIRD_LINK, FirebirdConstants.ANNUAL_REGISTRATION_URL_PATH_WITH_ID_PARAM + registration.getId()); parameterValues.put(FirebirdTemplateParameter.REGISTRATION_COORDINATOR, coordinator.getPerson()); verify(mockTemplateService).generateMessage( FirebirdMessageTemplate.COORDINATOR_COMPLETED_ANNUAL_REGISTRATION_EMAIL, parameterValues); }