List of usage examples for java.util EnumMap EnumMap
public EnumMap(Map<K, ? extends V> m)
From source file:org.openecomp.sdc.be.components.impl.ComponentBusinessLogic.java
protected Either<Boolean, ResponseFormat> validateUserRole(User user, Component component, List<Role> roles, AuditingActionEnum auditAction, String comment) { if (roles != null && roles.isEmpty()) { roles.add(Role.ADMIN);/*w w w . j a va 2s . c om*/ roles.add(Role.DESIGNER); } Either<Boolean, ResponseFormat> validationResult = validateUserRole(user, roles); if (validationResult.isRight()) { ComponentTypeEnum componentType = component.getComponentType(); EnumMap<AuditingFieldsKeysEnum, Object> additionalParams = new EnumMap<>(AuditingFieldsKeysEnum.class); if (componentType.equals(ComponentTypeEnum.SERVICE)) { additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_COMMENT, comment); String distributionStatus = ((ServiceMetadataDataDefinition) component .getComponentMetadataDefinition().getMetadataDataDefinition()).getDistributionStatus(); additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_DPREV_STATUS, distributionStatus); additionalParams.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_DCURR_STATUS, distributionStatus); } componentsUtils.auditComponent(validationResult.right().value(), user, component, "", "", auditAction, componentType, additionalParams); } return validationResult; }
From source file:org.openecomp.sdc.be.servlets.AbstractValidationsServlet.java
protected void validateResourceDoesNotExist(Wrapper<Response> responseWrapper, User user, String resourceName) { if (resourceImportManager.isResourceExist(resourceName)) { ResponseFormat responseFormat = getComponentsUtils() .getResponseFormat(ActionStatus.RESOURCE_ALREADY_EXISTS); Response errorResponse = buildErrorResponse(responseFormat); EnumMap<AuditingFieldsKeysEnum, Object> additionalParam = new EnumMap<AuditingFieldsKeysEnum, Object>( AuditingFieldsKeysEnum.class); additionalParam.put(AuditingFieldsKeysEnum.AUDIT_RESOURCE_NAME, resourceName); getComponentsUtils().auditResource(responseFormat, user, null, "", "", AuditingActionEnum.IMPORT_RESOURCE, additionalParam); responseWrapper.setInnerElement(errorResponse); }//from w w w .ja va 2 s . c o m }
From source file:org.yamj.core.database.dao.ApiDao.java
/** * Generate the query and load the results into the wrapper * * @param wrapper//from ww w . ja v a2 s .c om */ public void getVideoList(ApiWrapperList<ApiVideoDTO> wrapper) { SqlScalars sqlScalars = new SqlScalars(generateSqlForVideoList(wrapper)); OptionsIndexVideo options = (OptionsIndexVideo) wrapper.getOptions(); sqlScalars.addScalar(ID, LongType.INSTANCE); sqlScalars.addScalar("videoTypeString", StringType.INSTANCE); sqlScalars.addScalar(TITLE, StringType.INSTANCE); sqlScalars.addScalar(ORIGINAL_TITLE, StringType.INSTANCE); sqlScalars.addScalar(VIDEO_YEAR, IntegerType.INSTANCE); sqlScalars.addScalar(FIRST_AIRED, StringType.INSTANCE); sqlScalars.addScalar(SERIES_ID, LongType.INSTANCE); sqlScalars.addScalar(SEASON_ID, LongType.INSTANCE); sqlScalars.addScalar(SEASON, LongType.INSTANCE); DataItemTools.addDataItemScalars(sqlScalars, options.splitDataitems()); List<ApiVideoDTO> queryResults = executeQueryWithTransform(ApiVideoDTO.class, sqlScalars, wrapper); wrapper.setResults(queryResults); if (CollectionUtils.isNotEmpty(queryResults)) { if (CollectionUtils.isNotEmpty(options.getArtworkTypes())) { // Create and populate the ID list Map<MetaDataType, List<Long>> ids = new EnumMap<MetaDataType, List<Long>>(MetaDataType.class); for (MetaDataType mdt : MetaDataType.values()) { ids.put(mdt, new ArrayList()); } Map<String, ApiVideoDTO> results = new HashMap<String, ApiVideoDTO>(); for (ApiVideoDTO single : queryResults) { // Add the item to the map for further processing results.put(ApiArtworkDTO.makeKey(single), single); // Add the ID to the list ids.get(single.getVideoType()).add(single.getId()); } boolean foundArtworkIds = Boolean.FALSE; // Check to see that we have artwork to find // Remove any blank entries for (MetaDataType mdt : MetaDataType.values()) { if (CollectionUtils.isEmpty(ids.get(mdt))) { ids.remove(mdt); } else { // We've found an artwork, so we can continue foundArtworkIds = Boolean.TRUE; } } if (foundArtworkIds) { LOG.debug("Found artwork to process, IDs: {}", ids); addArtworks(ids, results, options); } else { LOG.debug("No artwork found to process, skipping."); } } else { LOG.debug("Artwork not required, skipping."); } } else { LOG.debug("No results found to process."); } }
From source file:forge.quest.io.QuestDataIO.java
/** * <p>/* w w w . j a v a 2 s . c om*/ * updateSaveFile. * </p> * * @param newData * a {@link forge.quest.data.QuestData} object. * @param input * a {@link java.lang.String} object. * @throws ParserConfigurationException * @throws IOException * @throws SAXException * @throws NoSuchFieldException * @throws IllegalAccessException */ private static void updateSaveFile(final QuestData newData, final String input, String filename) throws ParserConfigurationException, SAXException, IOException, IllegalAccessException, NoSuchFieldException { final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); final InputSource is = new InputSource(); is.setCharacterStream(new StringReader(input)); final Document document = builder.parse(is); final int saveVersion = newData.getVersionNumber(); if (saveVersion < 3) { QuestDataIO.setFinalField(QuestData.class, "assets", newData, new QuestAssets(null)); final int diffIdx = Integer .parseInt(document.getElementsByTagName("diffIndex").item(0).getTextContent()); QuestDataIO.setFinalField(QuestData.class, "achievements", newData, new QuestAchievements(diffIdx)); } if (saveVersion < 4) { QuestDataIO.setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(), new EnumMap<QuestItemType, Integer>(QuestItemType.class)); } if (saveVersion < 5) { QuestDataIO.setFinalField(QuestAssets.class, "combatPets", newData.getAssets(), new HashMap<String, QuestItemCondition>()); } if (saveVersion < 6) { QuestDataIO.setFinalField(QuestData.class, "petSlots", newData, new HashMap<>()); } if (saveVersion < 8) { QuestDataIO.setFinalField(QuestData.class, "isCharmActive", newData, false); } final QuestAssets qS = newData.getAssets(); final QuestAchievements qA = newData.getAchievements(); switch (saveVersion) { // There should be a fall-through between the cases so that each // version's changes get applied progressively case 0: // First beta release with new file format, // inventory needs to be migrated QuestDataIO.setFinalField(QuestAssets.class, "inventoryItems", newData.getAssets(), new EnumMap<QuestItemType, Integer>(QuestItemType.class)); qS.setItemLevel(QuestItemType.ESTATES, Integer.parseInt(document.getElementsByTagName("estatesLevel").item(0).getTextContent())); qS.setItemLevel(QuestItemType.LUCKY_COIN, Integer.parseInt(document.getElementsByTagName("luckyCoinLevel").item(0).getTextContent())); qS.setItemLevel(QuestItemType.SLEIGHT, Integer.parseInt(document.getElementsByTagName("sleightOfHandLevel").item(0).getTextContent())); final int gearLevel = Integer .parseInt(document.getElementsByTagName("gearLevel").item(0).getTextContent()); if (gearLevel >= 1) { newData.getAssets().setItemLevel(QuestItemType.MAP, 1); } if (gearLevel == 2) { newData.getAssets().setItemLevel(QuestItemType.ZEPPELIN, 1); } //$FALL-THROUGH$ case 1: // nothing to do here, everything is managed by CardPoolToXml // deserializer case 2: // questdata was divided into assets and achievements if (StringUtils.isBlank(newData.getName())) { QuestDataIO.setFinalField(QuestData.class, "name", newData, filename); } QuestDataIO.setFinalField(QuestAchievements.class, "win", qA, Integer.parseInt(document.getElementsByTagName("win").item(0).getTextContent())); QuestDataIO.setFinalField(QuestAchievements.class, "lost", qA, Integer.parseInt(document.getElementsByTagName("lost").item(0).getTextContent())); Node nw; if ((nw = document.getElementsByTagName("winstreakBest").item(0)) != null) { QuestDataIO.setFinalField(QuestAchievements.class, "winstreakBest", qA, Integer.parseInt(nw.getTextContent())); } if ((nw = document.getElementsByTagName("winstreakCurrent").item(0)) != null) { QuestDataIO.setFinalField(QuestAchievements.class, "winstreakCurrent", qA, Integer.parseInt(nw.getTextContent())); } QuestDataIO.setFinalField(QuestAchievements.class, "challengesPlayed", qA, Integer.parseInt(document.getElementsByTagName("challengesPlayed").item(0).getTextContent())); final List<Integer> completedChallenges = new ArrayList<>(); QuestDataIO.setFinalField(QuestAchievements.class, "completedChallenges", qA, completedChallenges); if ((nw = document.getElementsByTagName("completedChallenges").item(0)) != null) { final NodeList ccs = nw.getChildNodes(); for (int iN = 0; iN < ccs.getLength(); iN++) { final Node n0 = ccs.item(iN); if (n0.getNodeType() != Node.ELEMENT_NODE) { continue; } completedChallenges.add(Integer.parseInt(n0.getTextContent())); } } final XStream xs = QuestDataIO.getSerializer(true); QuestDataIO.setFinalField(QuestAssets.class, "credits", qS, Integer.parseInt(document.getElementsByTagName("credits").item(0).getTextContent())); QuestDataIO.setFinalField(QuestAssets.class, "cardPool", qS, QuestDataIO.readAsset(xs, document, "cardPool", ItemPool.class)); QuestDataIO.setFinalField(QuestAssets.class, "myDecks", qS, QuestDataIO.readAsset(xs, document, "myDecks", HashMap.class)); QuestDataIO.setFinalField(QuestAssets.class, "shopList", qS, QuestDataIO.readAsset(xs, document, "shopList", ItemPool.class)); QuestDataIO.setFinalField(QuestAssets.class, "newCardList", qS, QuestDataIO.readAsset(xs, document, "newCardList", ItemPool.class)); //$FALL-THROUGH$ case 3: // QuestInventory class no longer exists - KV pairs of // QuestItemPair => level moved to assets final Node oldInventory = saveVersion > 0 ? document.getElementsByTagName("inventory").item(1) : null; if (null != oldInventory) { for (int iN = 0; iN < oldInventory.getChildNodes().getLength(); iN++) { final Node _n = oldInventory.getChildNodes().item(iN); if (_n.getNodeType() != Node.ELEMENT_NODE) { continue; } final Element n = (Element) _n; final String name = n.getElementsByTagName("string").item(0).getTextContent(); final QuestItemType qType = QuestItemType.valueFromSaveKey(name); int level = 0; for (int iX = 0; iX < n.getChildNodes().getLength(); iX++) { final Node _x = n.getChildNodes().item(iX); if (_x.getNodeType() != Node.ELEMENT_NODE) { continue; } final Element x = (Element) _x; if (!x.getTagName().startsWith("forge.quest.data.")) { continue; } final String sLevel = x.getElementsByTagName("level").item(0).getTextContent(); if (StringUtils.isNotBlank(sLevel)) { level = Integer.parseInt(sLevel); } } qS.setItemLevel(qType, level); } } //$FALL-THROUGH$ case 4: if (saveVersion > 0) { NodeList pets = document.getElementsByTagName("pets").item(0).getChildNodes(); for (int i = 0; i < pets.getLength(); i++) { if (pets.item(i).getNodeType() != Node.ELEMENT_NODE) { continue; } final Element entry = (Element) pets.item(i); String name = entry.getElementsByTagName("string").item(0).getTextContent(); String sLevel = entry.getElementsByTagName("level").item(0).getTextContent(); qS.setPetLevel(name, Integer.parseInt(sLevel)); } } // pet manager will be re-engineered here //$FALL-THROUGH$ case 5: case 6: // have to convert completed challenges list members to strings. for (int i = qA.getLockedChallenges().size() - 1; i >= 0; i--) { Object lc = qA.getLockedChallenges().get(i); if (lc != null) { qA.getLockedChallenges().set(i, lc.toString()); } } for (int i = qA.getCurrentChallenges().size() - 1; i >= 0; i--) { Object lc = qA.getCurrentChallenges().get(i); if (lc != null) { qA.getCurrentChallenges().set(i, lc.toString()); } } //$FALL-THROUGH$ case 7: case 8: QuestDataIO.setFinalField(QuestAssets.class, "draftDecks", qS, new HashMap<String, DeckGroup>()); break; } // mark the QD as the latest version newData.setVersionNumber(QuestData.CURRENT_VERSION_NUMBER); }
From source file:io.lavagna.web.api.CardController.java
private void getMilestones(int projectId, Map<Integer, Integer> milestoneToIndex, List<MilestoneInfo> milestones) { CardLabel label = cardLabelRepository.findLabelByName(projectId, "MILESTONE", CardLabel.LabelDomain.SYSTEM); List<LabelListValueWithMetadata> listValues = cardLabelRepository.findListValuesByLabelId(label.getId()); int foundUnassignedIndex = -1; int mIndex = 0; for (LabelListValue milestone : listValues) { milestones/*w w w. ja v a 2 s . co m*/ .add(new MilestoneInfo(milestone, new EnumMap<ColumnDefinition, Long>(ColumnDefinition.class))); milestoneToIndex.put(milestone.getId(), mIndex); if ("Unassigned".equals(milestone.getValue())) { foundUnassignedIndex = mIndex; } mIndex++; } if (foundUnassignedIndex < 0) { LabelListValue unassigned = new LabelListValue(-1, 0, Integer.MAX_VALUE, "Unassigned"); milestones.add( new MilestoneInfo(unassigned, new EnumMap<ColumnDefinition, Long>(ColumnDefinition.class))); milestoneToIndex.put(null, milestoneToIndex.size()); } else { milestoneToIndex.put(null, foundUnassignedIndex); } }
From source file:org.libreplan.business.workingday.EffortDuration.java
public EnumMap<Granularity, Integer> decompose() { EnumMap<Granularity, Integer> result = new EnumMap<>(Granularity.class); int remainder = seconds; for (Granularity each : Granularity.fromMoreCoarseToLessCoarse()) { int value = each.convertFromSeconds(remainder); remainder -= value * each.toSeconds(1); result.put(each, value);//from w ww . j av a 2 s.c o m } assert remainder == 0; return result; }
From source file:com.adobe.acs.commons.mcp.impl.processes.asset.AssetIngestor.java
private synchronized EnumMap<ReportColumns, Object> trackActivity(String item, String action, String description, Long bytes) { if (reportRows == null) { reportRows = Collections.synchronizedList(new ArrayList<>()); }//from w ww . j a va2s. com EnumMap<ReportColumns, Object> reportRow = new EnumMap<>(ReportColumns.class); reportRow.put(ReportColumns.item, item); reportRow.put(ReportColumns.action, action); reportRow.put(ReportColumns.description, description); reportRow.put(ReportColumns.count, 0L); reportRow.put(ReportColumns.bytes, bytes); reportRows.add(reportRow); return reportRow; }
From source file:org.janusgraph.graphdb.database.log.TransactionLogHeader.java
public static Entry parse(StaticBuffer buffer, Serializer serializer, TimestampProvider times) { ReadBuffer read = buffer.asReadBuffer(); Instant txTimestamp = times.getTime(read.getLong()); TransactionLogHeader header = new TransactionLogHeader(VariableLong.readPositive(read), txTimestamp, times); LogTxStatus status = serializer.readObjectNotNull(read, LogTxStatus.class); EnumMap<LogTxMeta, Object> metadata = new EnumMap<LogTxMeta, Object>(LogTxMeta.class); int metaSize = VariableLong.unsignedByte(read.getByte()); for (int i = 0; i < metaSize; i++) { LogTxMeta meta = LogTxMeta.values()[VariableLong.unsignedByte(read.getByte())]; metadata.put(meta, serializer.readObjectNotNull(read, meta.dataType())); }/*from w ww. j a v a2 s . com*/ if (read.hasRemaining()) { StaticBuffer content = read.subrange(read.getPosition(), read.length() - read.getPosition()); return new Entry(header, content, status, metadata); } else { return new Entry(header, null, status, metadata); } }
From source file:net.unconventionalthinking.hierarchy.langsymboltable.LangSymbolTable_File.java
public LangSymbolTable_File(HierarchySettings hierarchySettings) { symbolTable_All = new HashMap<String, TreeMap<Integer, List<LangSymbol>>>(); symbolTable_bySymbolType = new EnumMap<LangSymbol.SymbolType, TreeMap<Integer, List<LangSymbol>>>( LangSymbol.SymbolType.class); symbolTable_bySymbolType__Worker = new LangSymbolTable_File__SymbolTableByType_Worker( symbolTable_bySymbolType);//from w ww.j a v a 2 s . co m symbolTable_Types = new HashMap<String, TreeMap<Integer, LangSymbol>>(); symbolTable_Types__typeBodyScopeid_to_TypeSym = new HashMap<Integer, LangSymbol_Type>(); symbolTable_Method__methodBodyScopeid_to_MethodSym = new HashMap<Integer, LangSymbol_Method>(); symbolTable_Vars = new HashMap<String, TreeMap<Integer, LangSymbol>>(); symbolTable_Methods = new HashMap<String, TreeMap<Integer, List<LangSymbol>>>(); symbolTable_Imports = new LinkedHashMap<String, LangSymbol_Import>(); symbolTable_Import_Package = new LinkedHashMap<String, LangSymbol_Import_Package>(); symbolTable_Import_Type = new LinkedHashMap<String, LangSymbol_Import_Type>(); symbolTable_Import_MPType__Matrix = new LinkedHashMap<String, LangSymbol_Import_Type>(); symbolTable_Import_MPType__Schema = new LinkedHashMap<String, LangSymbol_Import_Type>(); symbolTableMultiValueIndex_ImportType__bySimpleName = new HashMap<String, List<LangSymbol_Import_Type>>(); symbolTableMultiValueIndex_Import_MPType_Matrix__bySimpleName = new HashMap<String, List<LangSymbol_Import_Type>>(); symbolTableMultiValueIndex_Import_MPType_Schema__bySimpleName = new HashMap<String, List<LangSymbol_Import_Type>>(); matrixAccess_SymbolTableFile = new LangSymbolTable_File__forMatrixAccess(this, hierarchySettings); scopeStack = new LangSymbolScopeStack(hierarchySettings); typeInfo_List = new ArrayList<TypeInfo>(); this.hierarchySettings = hierarchySettings; }
From source file:tasly.greathealth.oms.web.inventory.rest.resources.ItemInfoResource.java
@SuppressWarnings("null") @PUT//from w ww . j a v a 2 s. c o m @Path("/flag0skus") public Response updateFlagSku(final SkuList skuList) throws Exception { int flag; EnumMap<HandleReturn, Object> handleReturn = new EnumMap<HandleReturn, Object>(HandleReturn.class); boolean updateStatus = false; final List<String> skus = skuList.getSkus(); if (skus.size() > 0 || skus != null) { for (final String sku : skus) { final ItemInfo itemInfo = itemInfoFacade.getBySku(sku); flag = itemInfo.getStockManageFlag(); if (flag == 0) { final List<TaslyItemLocationData> checkTaslyItemLocationDatas = taslyItemLocationService .getByItemID(sku); if (checkTaslyItemLocationDatas == null || checkTaslyItemLocationDatas.size() == 0) { omsLOG.error("sku:" + sku + ",no ItemLocation data!"); continue; } else { try { handleReturn = itemQuantityService.handleUpdateMethod(checkTaslyItemLocationDatas, sku, flag, 0); } catch (final Exception e) { omsLOG.error("handle sku:" + sku + " failed and error is " + e); handleReturn.put(HandleReturn.handleStatus, false); } if ((boolean) handleReturn.get(HandleReturn.handleStatus)) { try { updateStatus = itemQuantityService.updateMethod(sku, flag, 0); if (updateStatus) { omsLOG.debug("sku:" + sku + ",flag=0 allocated ok!"); } } catch (final Exception e) { omsLOG.error("update sku:" + sku + " failed and error is " + e); } } } } } omsLOG.info("Update quantity where flag=0 finished."); } return Response.status(Response.Status.OK).build(); }