List of usage examples for java.lang Long equals
public boolean equals(Object obj)
From source file:burstcoin.observer.service.ATService.java
private void startCheckAutomatedTransactionsTask() { timer.schedule(new TimerTask() { @Override/* w w w .ja v a 2 s . c o m*/ public void run() { try { LOG.info("START import at data"); Map<String, AutomatedTransaction> atLookup = new HashMap<>(); for (String atId : getAutomatedTransactionIds()) { AutomatedTransaction automatedTransaction = getAutomatedTransaction(atId); atLookup.put(atId, automatedTransaction); } State state = getState(); LOG.info("FINISH import at data!"); Long currentBlock = state.getNumberOfBlocks(); List<CrowdfundBean> crowdfundBeans = new ArrayList<>(); // different by code?! Map<String, List<AutomatedTransaction>> atByCodeLookup = new HashMap<>(); for (AutomatedTransaction automatedTransaction : atLookup.values()) { if (!atByCodeLookup.containsKey(automatedTransaction.getMachineCode())) { atByCodeLookup.put(automatedTransaction.getMachineCode(), new ArrayList<>()); } atByCodeLookup.get(automatedTransaction.getMachineCode()).add(automatedTransaction); } for (Map.Entry<String, List<AutomatedTransaction>> entry : atByCodeLookup.entrySet()) { // filter for crowdfund if (entry.getKey().contains(CROWDFUND_AT_CODE)) { for (AutomatedTransaction at : entry.getValue()) { // target amount String targetAmountHex = at.getMachineData().substring(48, 64); String targetAmount = getATLong(targetAmountHex); String targetAmountInt = targetAmount.length() > 8 ? targetAmount.substring(0, targetAmount.length() - 8) : targetAmount; String decisionHex = at.getMachineData().substring(16, 32); Integer decision = Integer.valueOf(getATLong(decisionHex)); String transactionHex = at.getMachineData().substring(8, 16); Integer transaction = Integer.valueOf(getATLong(transactionHex)); Long ends = transaction + decision - currentBlock; Long running = currentBlock - transaction; String fundedHex = at.getMachineData().substring(7 * 16, 7 * 16 + 16); String funded = getATLong(fundedHex); CrowdfundState cfState = CrowdfundState.ACTIVE; switch (funded) { case "2": cfState = CrowdfundState.NOT_FUNDED; break; case "1": cfState = CrowdfundState.FUNDED; break; } // skip active that never got started/funded while running if ((ends > 0 || !CrowdfundState.ACTIVE.equals(cfState)) && !blacklistedAtRS.contains(at.getAtRS())) { String current = "0"; if (at.getBalanceNQT().length() > 8) { current = at.getBalanceNQT().substring(0, at.getBalanceNQT().length() - 8); } if (CrowdfundState.FUNDED.equals(cfState) || CrowdfundState.NOT_FUNDED.equals(cfState)) { String gatheredAmountHex = at.getMachineData().substring(32, 48); String gatheredAmount = getATLong(gatheredAmountHex); if (gatheredAmount.length() > 8) { current = gatheredAmount.substring(0, gatheredAmount.length() - 8); } } double percent = getPercentageCorrect(Integer.valueOf(targetAmountInt), Integer.valueOf(current)); int round = Math.round((float) percent); round = round > 100 ? 100 : round; crowdfundBeans.add(new CrowdfundBean(at.getAt(), at.getAtRS(), at.getCreatorRS(), at.getName(), at.getDescription().length() > 9 ? at.getDescription().substring(0, at.getDescription().length() - 9) : at.getDescription(), cfState, targetAmountInt, current, round + "", percent, ends.equals(currentBlock) ? "N/A" : String.valueOf(ends))); } } Collections.sort(crowdfundBeans, new Comparator<CrowdfundBean>() { @Override public int compare(CrowdfundBean o1, CrowdfundBean o2) { return Long.valueOf(o2.getCurrentAmount()) .compareTo(Long.valueOf(o1.getCurrentAmount())); } }); Collections.sort(crowdfundBeans, new Comparator<CrowdfundBean>() { @Override public int compare(CrowdfundBean o1, CrowdfundBean o2) { return o1.getState().compareTo(o2.getState()); } }); // todo no idea why this currently does not work // context.publishEvent(new CrowdfundUpdateEvent(crowdfundBeans)); // workaround: context.getBean(CrowdfundController.class) .handleMessage(new CrowdfundUpdateEvent(crowdfundBeans)); } } } catch (Exception e) { LOG.error("Failed update crowdfund data"); } } }, 200, ObserverProperties.getCrowdfundRefreshInterval()); }
From source file:org.apache.click.control.Form.java
/** * Perform a back button submit check, returning true if the request is * valid or false otherwise. This method will add a submit check token * to the form as a hidden field, and to the session. * * @return true if the submit is OK or false otherwise *//*w w w . ja v a 2 s . c o m*/ protected boolean performSubmitCheck() { if (StringUtils.isBlank(getName())) { throw new IllegalStateException("Form name is not defined."); } // CLK-333. Don't regenerate submit tokens for Ajax requests. Context context = getContext(); if (context.isAjaxRequest()) { return true; } String resourcePath = context.getResourcePath(); int slashIndex = resourcePath.indexOf('/'); if (slashIndex != -1) { resourcePath = resourcePath.replace('/', '_'); } // Ensure resourcePath starts with a '_' separator. If slashIndex == -1 // or slashIndex > 0, resourcePath does not start with slash. if (slashIndex != 0) { resourcePath = '_' + resourcePath; } final HttpServletRequest request = context.getRequest(); final String submitTokenName = SUBMIT_CHECK + getName() + resourcePath; boolean isValidSubmit = true; // If not this form exit String formName = context.getRequestParameter(FORM_NAME); // Only test if submit for this form if (!context.isForward() && request.getMethod().equalsIgnoreCase(getMethod()) && getName().equals(formName)) { Long sessionTime = (Long) context.getSessionAttribute(submitTokenName); if (sessionTime != null) { String value = context.getRequestParameter(submitTokenName); if (value == null || value.length() == 0) { // CLK-289. If a session attribute exists for the // SUBMIT_CHECK, but no request parameter, we assume the // submission is a duplicate and therefore invalid. LogService logService = ClickUtils.getLogService(); logService.warn(" 'Redirect After Post' token called '" + submitTokenName + "' is registered in the session, " + "but no matching request parameter was found. " + "(form name: '" + getName() + "'). To protect against a 'duplicate post', " + "Form.onSubmitCheck() will return false."); isValidSubmit = false; } else { Long formTime = Long.valueOf(value); isValidSubmit = formTime.equals(sessionTime); } } } // CLK-267: check against adding a duplicate field HiddenField field = (HiddenField) getField(submitTokenName); if (field == null) { field = new NonProcessedHiddenField(submitTokenName, Long.class); add(field); insertIndexOffset++; } // Save state info to form and session final Long time = System.currentTimeMillis(); field.setValueObject(time); context.setSessionAttribute(submitTokenName, time); if (isValidSubmit) { return true; } else { return false; } }
From source file:org.openmeetings.app.remote.ChatService.java
/** * sends a Chat-Message/* www . j av a 2s . c o m*/ * to all members of the Chatroom * and all additional users (waitng for a free entry for example) * @param newMessage * @return */ @SuppressWarnings({ "rawtypes", "unchecked" }) public int sendMessageWithClient(Object newMessage) { try { IConnection current = Red5.getConnectionLocal(); RoomClient currentClient = this.clientListManager.getClientByStreamId(current.getClient().getId()); Long room_id = currentClient.getRoom_id(); log.debug("room_id: " + room_id); log.debug("currentClient.getIsChatNotification(): " + currentClient.getIsChatNotification()); if (currentClient.getIsChatNotification()) { room_id = currentClient.getChatUserRoomId(); } //log.error(newMessage.getClass().getName()); ArrayList messageMap = (ArrayList) newMessage; //adding delimiter space, cause otherwise an emoticon in the last string would not be found String messageText = messageMap.get(4).toString() + " "; //log.error("messageText"+messageText); //add server time messageMap.set(1, parseDateAsTimeString()); LinkedList<String[]> parsedStringObjects = ChatString.getInstance().parseChatString(messageText); //log.error("parsedStringObjects"+parsedStringObjects.size()); log.debug("size:" + messageMap.size()); messageMap.add(parsedStringObjects); newMessage = messageMap; HashMap<String, Object> hsm = new HashMap<String, Object>(); hsm.put("client", currentClient); hsm.put("message", newMessage); List<HashMap<String, Object>> myChatList = myChats.get(room_id); if (myChatList == null) myChatList = new LinkedList<HashMap<String, Object>>(); if (myChatList.size() == chatRoomHistory) myChatList.remove(0); myChatList.add(hsm); myChats.put(room_id, myChatList); log.debug("SET CHATROOM: " + room_id); //broadcast to everybody in the room/domain Collection<Set<IConnection>> conCollection = current.getScope().getConnections(); for (Set<IConnection> conset : conCollection) { for (IConnection conn : conset) { if (conn != null) { if (conn instanceof IServiceCapableConnection) { RoomClient rcl = this.clientListManager.getClientByStreamId(conn.getClient().getId()); if (rcl == null) { continue; } if (rcl.getIsAVClient()) { continue; } if (rcl.getIsScreenClient() != null && rcl.getIsScreenClient()) { continue; } log.debug("*..*idremote room_id: " + room_id); log.debug("*..*my idstreamid room_id: " + rcl.getRoom_id()); if (room_id != null && room_id.equals(rcl.getRoom_id())) { ((IServiceCapableConnection) conn).invoke("sendVarsToMessageWithClient", new Object[] { hsm }, this); log.debug("sending sendVarsToMessageWithClient to " + conn); } else if (rcl.getIsChatNotification()) { if (room_id.equals(rcl.getChatUserRoomId()) && room_id != null) { ((IServiceCapableConnection) conn).invoke("sendVarsToMessageWithClient", new Object[] { hsm }, this); } } } } } } } catch (Exception err) { log.error("[ChatService sendMessageWithClient] ", err); return -1; } return 1; }
From source file:burstcoin.observer.service.NetworkService.java
private void processMiningInfoLookup(Map<String, MiningInfo> miningInfoLookup) { List<NetworkBean> networkBeans = new ArrayList<>(); for (Map.Entry<String, MiningInfo> entry : miningInfoLookup.entrySet()) { MiningInfo miningInfo = entry.getValue(); String https = entry.getKey().contains("https://") ? "Yes" : "No"; String domain = entry.getKey().replace("http://", "").replace("https://", ""); if (miningInfo != null && miningInfo.getGenerationSignature() != null) { networkBeans.add(new NetworkBean(String.valueOf(miningInfo.getHeight()), domain, entry.getKey(), miningInfo.getBaseTarget(), miningInfo.getGenerationSignature().substring(0, 25) + "...", String.valueOf(miningInfo.getTargetDeadline()), https)); } else {/*from w ww . j av a 2s.c o m*/ networkBeans.add(new NetworkBean(domain)); } } Collections.sort(networkBeans, new Comparator<NetworkBean>() { @Override public int compare(NetworkBean o1, NetworkBean o2) { return o1.getBaseTarget().compareTo(o2.getBaseTarget()); } }); Collections.sort(networkBeans, new Comparator<NetworkBean>() { @Override public int compare(NetworkBean o1, NetworkBean o2) { return o1.getType().compareTo(o2.getType()); } }); Collections.sort(networkBeans, new Comparator<NetworkBean>() { @Override public int compare(NetworkBean o1, NetworkBean o2) { return o2.getHeight().compareTo(o1.getHeight()); } }); // update genSig Lookup int numberOfNotAvailableDomains = 0; for (NetworkBean networkBean : networkBeans) { if (networkBean.getAvailable()) { Long height = Long.valueOf(networkBean.getHeight()); if (!genSigLookup.containsKey(height)) { genSigLookup.put(height, new HashMap<>()); } Map<String, Set<String>> subMap = genSigLookup.get(height); if (!subMap.containsKey(networkBean.getGenerationSignature())) { subMap.put(networkBean.getGenerationSignature(), new HashSet<>()); } Set<String> domains = subMap.get(networkBean.getGenerationSignature()); domains.add(networkBean.getDomain()); } else { // N/A numberOfNotAvailableDomains++; } } List<Long> order = new ArrayList<>(genSigLookup.keySet()); Collections.sort(order); Collections.reverse(order); Iterator<Long> iterator = order.iterator(); Long lastBlockWithSameGenSig = null; while (iterator.hasNext() && lastBlockWithSameGenSig == null) { Long nextHeight = iterator.next(); if (genSigLookup.get(nextHeight).size() == 1) // only one known genSig for height { // number of domains with same genSig = all domains without N/A if (networkBeans.size() - numberOfNotAvailableDomains == genSigLookup.get(nextHeight).values() .iterator().next().size()) { lastBlockWithSameGenSig = nextHeight; } } } long maxHeight = 0; for (NetworkBean networkBean : networkBeans) { if (networkBean.getAvailable()) { maxHeight = Math.max(Long.valueOf(networkBean.getHeight()), maxHeight); } } boolean appStartedAfterForkHappened = lastBlockWithSameGenSig == null; boolean sendMail = false; for (NetworkBean networkBean : networkBeans) { if (networkBean.getAvailable()) { Long height = Long.valueOf(networkBean.getHeight()); Set<String> domainsWithSameGenSigForBlock = genSigLookup.get(height) .get(networkBean.getGenerationSignature()); if (genSigLookup.get(height).size() > 1 && domainsWithSameGenSigForBlock .size() < (networkBeans.size() - numberOfNotAvailableDomains) / 2) { networkBean.setState(NetworkState.FORKED); sendMail = true; } if (height + 4 < maxHeight) // when the wallet is 4 blocks behind -> stuck { if (!networkBean.getState().equals(NetworkState.FORKED)) // if it's forked, then ignore the stuck-check, because forks may also be behind { networkBean.setState(NetworkState.STUCK); if (ObserverProperties.isEnableStuckNotify() && (!previousStateLookup .containsKey(networkBean.getDomain()) || !previousStateLookup.get(networkBean.getDomain()).equals(NetworkState.STUCK))) //send only once { sendMessage("Burstcoin-Observer - Stuck at block: " + networkBean.getHeight(), networkBean.getDomain() + "\r\n" + "Please check: " + ObserverProperties.getObserverUrl()); } } } } } if (sendMail && !forkMailSend) { if (ObserverProperties.isEnableForkNotify() && (appStartedAfterForkHappened || (lastBlockWithSameGenSigMailSend != null && !lastBlockWithSameGenSig.equals(lastBlockWithSameGenSigMailSend)))) { forkMailSend = true; // ensure only one mail send per lastBlockWithSameGenSig e.g. if forked wallet pops off blocks over and over again lastBlockWithSameGenSigMailSend = lastBlockWithSameGenSig; sendMessage("Burstcoin-Observer - Fork after block: " + lastBlockWithSameGenSig, "Please check: " + ObserverProperties.getObserverUrl()); } } else if (!sendMail && !appStartedAfterForkHappened) { forkMailSend = false; } // store the network state for next check-loop for (NetworkBean networkBean : networkBeans) { if (networkBean.getAvailable() && networkBean.getDomain() != null) { previousStateLookup.put(networkBean.getDomain(), networkBean.getState()); } } publisher.publishEvent( new NetworkUpdateEvent(networkBeans, lastBlockWithSameGenSig, createSenkeyChartData())); }
From source file:com.wizecommerce.hecuba.HecubaCassandraManagerTestBase.java
@Test public void testReadColumnSliceMultipleKeys() throws Exception { logger.info("Testing Hector read column slice with multiple keys"); HecubaClientManager<Long> cassandraManager = getHecubaClientManager(); HashMap<String, Object> row1 = new HashMap<String, Object>(); /**********************************************************/ /****** TEST CASSANDRA ROWS CONTAINS > 100 COLUMNS ********/ /**********************************************************/ Long key1 = 1234L; // Insert 200 columns in cassandra for key1 for (int i = 1; i <= 200; i++) { row1.put("column_" + i, "value_" + i); }/*from ww w . ja va 2 s. c o m*/ cassandraManager.updateRow(key1, row1); // Insert 150 columns in cassandra for key2 HashMap<String, Object> row2 = new HashMap<String, Object>(); Long key2 = 5678L; for (int i = 1; i <= 150; i++) { row2.put("column_" + i, "value_" + i); } cassandraManager.updateRow(key2, row2); Set<Long> keys = new HashSet<Long>(); keys.add(key1); keys.add(key2); /** * ___________________________________________________________ | Retrieve all columns for all keys (no of columns < 10000) * ----------------------------------------------------------- */ CassandraResultSet<Long, String> result = cassandraManager.readColumnSliceAllColumns(keys); Set<Long> keysCopy = new HashSet<Long>(keys); int count = 0; assertNotNull(result); /** * NOTE: We are using [while(true) --> break] loop here because CassandraResultSet points to the first row when its created. CassandraResultSet.hasNextResult returns true * if there are any more rows and CassandraResultSet.nextResult () moves the pointer to the next row. So in the loop, we needed the processing --> check break condition --> * move the pointer. */ while (true) { count++; assertEquals(true, keysCopy.remove(result.getKey())); if (key1.equals(result.getKey())) { // Column count should be 200 assertEquals(200, result.getColumnNames().size()); for (String columnName : row1.keySet()) { assertEquals(row1.get(columnName), result.getString(columnName)); } } else if (key2.equals(result.getKey())) { // Column count should be 150 assertEquals(150, result.getColumnNames().size()); for (String columnName : row2.keySet()) { assertEquals(row2.get(columnName), result.getString(columnName)); } } if (!result.hasNextResult()) { break; } result.nextResult(); } assertEquals(keys.size(), count); // Asserts the result set contains exactly same number of rows as is the // keys size assertEquals(0, keysCopy.size()); // Asserts we get both the keys in the result set /*************************************************************************/ /****** TEST CASSANDRA ROWS CONTAINS < 100 COLUMNS + A MISS ROW ********/ /*************************************************************************/ cassandraManager.deleteRow(key1); cassandraManager.deleteRow(key2); long key3 = 9999L; keys.add(key3); row1.clear(); for (int i = 1; i <= 80; i++) { row1.put("column_" + i, "value_" + i); } cassandraManager.updateRow(key1, row1); row2.clear(); for (int i = 1; i <= 60; i++) { row2.put("column_" + i, "value_" + i); } cassandraManager.updateRow(key2, row2); /** * ____________________________________ | Retrieve all columns for all keys ------------------------------------ */ result = cassandraManager.readColumnSliceAllColumns(keys); keysCopy = new HashSet<Long>(keys); count = 0; assertNotNull(result); /** * NOTE: We are using [while(true) --> break] loop here because CassandraResultSet points to the first row when its created. CassandraResultSet.hasNextResult returns true * if there are any more rows and CassandraResultSet.nextResult () moves the pointer to the next row. So in the loop, we needed the processing --> check break condition --> * move the pointer. */ while (true) { if (result.getColumnNames().size() > 0) { // Only count rows that actually contain results count++; } assertEquals(true, keysCopy.remove(result.getKey())); if (result.getKey().equals(key1)) { // Column count should be 80 assertEquals(80, result.getColumnNames().size()); for (String columnName : row1.keySet()) { assertEquals(row1.get(columnName), result.getString(columnName)); } } else if (result.getKey().equals(key2)) { // Column count should be 60 assertEquals(60, result.getColumnNames().size()); for (String columnName : row2.keySet()) { assertEquals(row2.get(columnName), result.getString(columnName)); } } else if (result.getKey().equals(key3)) { // Column count should be 0 since key3 doesn't exist assertEquals(0, result.getColumnNames().size()); } if (!result.hasNextResult()) { break; } result.nextResult(); } assertEquals(2, count); // Asserts 2 rows contained data if (keysCopy.size() == 1) { // key3 did not exist in cassandra so CQL will not return it assertTrue(keysCopy.contains(key3)); } else { assertEquals(0, keysCopy.size()); // Asserts we get all the keys in the result set } }
From source file:edu.harvard.iq.dvn.core.web.ExploreDataPage.java
private void loadFilterGroups(List<VarGroup> inList) { inList.clear();/* w w w . j a va 2 s.c o m*/ List<VarGroup> localVGList = new ArrayList(); Iterator i = filterGroupMeasureAssociation.listIterator(); int count = 0; while (i.hasNext()) { Object test = i.next(); if (count % 2 == 0) { Long id = (Long) test; if (id.equals(selectedMeasureId)) { localVGList.add((VarGroup) i.next()); count++; } } count++; } for (VarGroup varGroup : localVGList) { inList.add(varGroup); } }
From source file:edu.harvard.iq.dvn.core.web.ExploreDataPage.java
private List<VarGroup> getFilterGroupsFromMeasureId(Long MeasureId) { List returnList = new ArrayList(); List<VarGroup> localVGList = new ArrayList(); Iterator i = filterGroupMeasureAssociation.listIterator(); int count = 0; while (i.hasNext()) { Object test = i.next();//from ww w . j av a 2 s.c o m if (count % 2 == 0) { Long id = (Long) test; if (id.equals(MeasureId)) { localVGList.add((VarGroup) i.next()); count++; } } count++; } for (VarGroup varGroup : localVGList) { returnList.add(varGroup); } return returnList; }
From source file:edu.harvard.iq.dvn.core.web.ExploreDataPage.java
private void loadFilterGroupTypes(List<VarGroupTypeUI> inList, Long groupingId) { List<VarGroupType> localVGList = new ArrayList(); Iterator i = groupingTypeAssociation.listIterator(); int count = 0; while (i.hasNext()) { Object test = i.next();// w w w . ja v a 2 s.com if (count % 2 == 0) { Long id = (Long) test; if (id.equals(groupingId)) { localVGList.add((VarGroupType) i.next()); count++; } } count++; } List<VarGroup> varGroupsAll = (List<VarGroup>) getFilterGroupsFromMeasureId(selectedMeasureId); List<VarGroupType> varGroupTypesAll = new ArrayList(); for (VarGroup varGroupFilter : varGroupsAll) { for (VarGroupType vgt : varGroupFilter.getGroupTypes()) { varGroupTypesAll.add(vgt); } } for (VarGroupType varGroupType : localVGList) { if (varGroupTypesAll.contains(varGroupType)) { VarGroupTypeUI varGroupTypeUI = new VarGroupTypeUI(); varGroupTypeUI.setVarGroupType(varGroupType); varGroupTypeUI.setEnabled(false); inList.add(varGroupTypeUI); } } }
From source file:edu.harvard.iq.dvn.core.web.ExploreDataPage.java
private void loadFilterGroupings() { filterStrings.clear();/*from w ww.j a v a 2s. c o m*/ filterGroupings.clear(); filterGroupingsAndFilters = new HashMap(); List<VarGrouping> localVGList = new ArrayList(); Iterator i = filterGroupingMeasureAssociation.listIterator(); int count = 0; //need iterator here because we are dealing with objects of varying types and // we need to jump ahead wheh the id is eqaul to the selected measure id while (i.hasNext()) { Object test = i.next(); if (count % 2 == 0) { Long id = (Long) test; if (id.equals(selectedMeasureId)) { localVGList.add((VarGrouping) i.next()); count++; } } count++; } for (VarGrouping varGrouping : localVGList) { if (varGrouping.getGroupingType().equals(GroupingType.FILTER)) { List<VarGroup> filterGroups = new ArrayList(); List<VarGroupTypeUI> filterGroupTypes = new ArrayList(); VarGroupingUI vgUI = new VarGroupingUI(); vgUI.setVarGrouping(varGrouping); loadFilterGroups(filterGroups); loadFilterGroupTypes(filterGroupTypes, varGrouping.getId()); vgUI.setVarGroupTypesUI(filterGroupTypes); selectedMeasureHasFilters = true; if (!filterGroupTypes.isEmpty()) { selectedMeasureHasFilterTypes = true; } vgUI.setSelectedGroupId(new Long(0)); filterGroupings.add(vgUI); } } for (VarGrouping varGrouping : localVGList) { Map filterGroupingFilterMap = getFilterGroupsMap(varGrouping.getId()); filterGroupingsAndFilters.put(varGrouping.getId(), filterGroupingFilterMap); } }
From source file:jp.primecloud.auto.service.impl.ComponentServiceImpl.java
/** * {@inheritDoc}/*w w w .java 2s . c o m*/ */ @Override public ComponentTypeDto getComponentType(Long componentNo) { // ???? Component component = componentDao.read(componentNo); // ???? ComponentType componentType = componentTypeDao.read(component.getComponentTypeNo()); // ? List<Instance> instances = new ArrayList<Instance>(); List<Instance> allInstances = instanceDao.readByFarmNo(component.getFarmNo()); for (Instance instance : allInstances) { // ? if (BooleanUtils.isTrue(instance.getLoadBalancer())) { continue; } instances.add(instance); } // ???? List<Component> components = componentDao.readByFarmNo(component.getFarmNo()); // ? List<Long> availableInstanceNos = new ArrayList<Long>(); // ?????? for (Instance instance : instances) { Image image = imageDao.read(instance.getImageNo()); String[] componentTypeNos = StringUtils.split(image.getComponentTypeNos(), ","); boolean available = false; for (String componentTypeNo : componentTypeNos) { if (componentType.getComponentTypeNo().equals(Long.parseLong(componentTypeNo.trim()))) { available = true; break; } } if (available) { availableInstanceNos.add(instance.getInstanceNo()); } } // ?????????????????????????? for (Component component2 : components) { if (componentNo.equals(component2.getComponentNo())) { continue; } ComponentType componentType2 = componentTypeDao.read(component2.getComponentTypeNo()); if (StringUtils.equals(componentType.getLayer(), componentType2.getLayer())) { List<ComponentInstance> componentInstances = componentInstanceDao .readByComponentNo(component2.getComponentNo()); for (ComponentInstance componentInstance : componentInstances) { ComponentInstanceStatus status = ComponentInstanceStatus .fromStatus(componentInstance.getStatus()); if (BooleanUtils.isTrue(componentInstance.getAssociate()) || status != ComponentInstanceStatus.STOPPED) { availableInstanceNos.remove(componentInstance.getInstanceNo()); } } } } // DTO?? ComponentTypeDto dto = new ComponentTypeDto(); dto.setComponentType(componentType); dto.setInstanceNos(availableInstanceNos); return dto; }