List of usage examples for java.lang Integer equals
public boolean equals(Object obj)
From source file:org.o3project.optsdn.don.NetworkInformation.java
/** * Get informations from IDEx file(idex.txt). * - DP ID/*from w w w .j a v a2s . c o m*/ * - OF Port * * @param filepath The IDEx file path * @throws Exception File Read Failed */ private void parseIdExFile(String filepath) throws Exception { String idexJson = readIdexAsJson(filepath); ObjectMapper mapper = new ObjectMapper(); @SuppressWarnings("unchecked") Map<String, Map<String, String>> value = mapper.readValue(idexJson, Map.class); Set<Entry<String, Map<String, String>>> entrySet = value.entrySet(); dpidMap = new HashMap<String, Long>(); Map<String, Integer> ofPortMap = new HashMap<String, Integer>(); for (Entry<String, Map<String, String>> entry : entrySet) { Map<String, String> params = entry.getValue(); BigInteger bigintDpid = new BigInteger(params.get(DPID)); if (bigintDpid.compareTo(BigInteger.valueOf(0)) < 0 || bigintDpid.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) > 0) { throw new Exception("DP ID is out of boundary. (DP ID valid between 0 and 2^63-1)"); } long dpid = bigintDpid.longValue(); String informationModelId = entry.getKey(); Port port = new Port(informationModelId); String neId = port.getNeId(); Long existDpid = dpidMap.get(neId); if (existDpid == null) { dpidMap.put(neId, dpid); } else if (!existDpid.equals(dpid)) { logger.warn("Fail to add DP ID[" + dpid + "]. " + "The DP ID of NE[" + neId + "] is already set" + "(exist DP ID[" + existDpid + "])."); } int ofPortId = Integer.valueOf(params.get(PORT)); Integer existOfPortId = ofPortMap.get(informationModelId); if (existOfPortId != null) { if (!existOfPortId.equals(ofPortId)) { logger.warn("Fail to add OpenFlow Port ID[" + ofPortId + "]. " + "The OpenFlow Port ID of Port[" + informationModelId + "] is already set" + "(exist OpenFlow Port ID[" + existOfPortId + "])."); } } else { if (ofPortId < 0 && ofPortId > Integer.MAX_VALUE) { throw new Exception("OpenFlow Port ID is out of boundary. " + "(OpenFlow Port ID valid between 0 and 2^31-1)"); } ofPortMap.put(informationModelId, ofPortId); } } for (Port port : portSet) { Integer openFlowPortId = ofPortMap.get(port.getInformationModelId()); if (openFlowPortId == null) { continue; } port.setOpenFlowPortId(openFlowPortId); } for (List<List<Port>> linkList : omsConnectionInfoListMap.values()) { for (List<Port> link : linkList) { Port port1 = link.get(0); Integer openFlowPortId1 = ofPortMap.get(port1.getInformationModelId()); if (openFlowPortId1 != null) { port1.setOpenFlowPortId(openFlowPortId1); } Port port2 = link.get(1); Integer openFlowPortId2 = ofPortMap.get(port2.getInformationModelId()); if (openFlowPortId2 != null) { port2.setOpenFlowPortId(openFlowPortId2); } } } }
From source file:com.sapienter.jbilling.server.process.AgeingBL.java
public void setUserStatus(Integer executorId, Integer userId, Integer statusId, Date today) { // find out if this user is not already in the required status UserBL user = new UserBL(userId); Integer originalStatusId = user.getEntity().getStatus().getId(); if (originalStatusId.equals(statusId)) { return;// w ww .j av a 2 s. co m } LOG.debug("Setting user " + userId + " status to " + statusId); // see if this guy could login in her present status boolean couldLogin = user.getEntity().getStatus().getCanLogin() == 1; // log an event if (executorId != null) { // this came from the gui eLogger.audit(executorId, userId, Constants.TABLE_BASE_USER, user.getEntity().getUserId(), EventLogger.MODULE_USER_MAINTENANCE, EventLogger.STATUS_CHANGE, user.getEntity().getStatus().getId(), null, null); } else { // this is from a process, no executor involved eLogger.auditBySystem(user.getEntity().getEntity().getId(), userId, Constants.TABLE_BASE_USER, user.getEntity().getUserId(), EventLogger.MODULE_USER_MAINTENANCE, EventLogger.STATUS_CHANGE, user.getEntity().getStatus().getId(), null, null); } // make the notification NotificationBL notification = new NotificationBL(); try { MessageDTO message = notification.getAgeingMessage(user.getEntity().getEntity().getId(), user.getEntity().getLanguageIdField(), statusId, userId); INotificationSessionBean notificationSess = (INotificationSessionBean) Context .getBean(Context.Name.NOTIFICATION_SESSION); notificationSess.notify(user.getEntity(), message); } catch (NotificationNotFoundException e) { LOG.warn("Changeing the satus of a user. An ageing notification " + "should be " + "sent to the user, but the entity doesn't have it. " + "entity " + user.getEntity().getEntity().getId()); } // make the change UserStatusDTO status = new UserStatusDAS().find(statusId); user.getEntity().setUserStatus(status); user.getEntity().setLastStatusChange(today); if (status.getId() == UserDTOEx.STATUS_DELETED) { // yikes, it's out user.delete(executorId); return; // her orders were deleted, no need for any change in status } // see if this new status is suspended if (couldLogin && status.getCanLogin() == 0) { // all the current orders have to be suspended OrderDAS orderDas = new OrderDAS(); OrderBL order = new OrderBL(); for (Iterator it = orderDas.findByUser_Status(userId, Constants.ORDER_STATUS_ACTIVE).iterator(); it .hasNext();) { OrderDTO orderRow = (OrderDTO) it.next(); order.set(orderRow); order.setStatus(executorId, Constants.ORDER_STATUS_SUSPENDED_AGEING); } } else if (!couldLogin && status.getCanLogin() == 1) { // the oposite, it is getting out of the ageing process // all the suspended orders have to be reactivated OrderDAS orderDas = new OrderDAS(); OrderBL order = new OrderBL(); for (Iterator it = orderDas.findByUser_Status(userId, Constants.ORDER_STATUS_SUSPENDED_AGEING) .iterator(); it.hasNext();) { OrderDTO orderRow = (OrderDTO) it.next(); order.set(orderRow); order.setStatus(executorId, Constants.ORDER_STATUS_ACTIVE); } } // make the http call back String url = null; try { PreferenceBL pref = new PreferenceBL(); pref.set(user.getEntity().getEntity().getId(), Constants.PREFERENCE_URL_CALLBACK); url = pref.getString(); } catch (EmptyResultDataAccessException e2) { // no call then } if (url != null && url.length() > 0) { // get the url connection try { LOG.debug("Making callback to " + url); // cook the parameters to be sent NameValuePair[] data = new NameValuePair[6]; data[0] = new NameValuePair("cmd", "ageing_update"); data[1] = new NameValuePair("user_id", userId.toString()); data[2] = new NameValuePair("login_name", user.getEntity().getUserName()); data[3] = new NameValuePair("from_status", originalStatusId.toString()); data[4] = new NameValuePair("to_status", statusId.toString()); data[5] = new NameValuePair("can_login", String.valueOf(status.getCanLogin())); // make the call HttpClient client = new HttpClient(); client.setConnectionTimeout(30000); PostMethod post = new PostMethod(url); post.setRequestBody(data); client.executeMethod(post); } catch (Exception e1) { LOG.info("Could not make call back. url = " + url + " Message:" + e1.getMessage()); } } // trigger NewUserStatusEvent EventManager.process( new NewUserStatusEvent(user.getDto().getCompany().getId(), userId, originalStatusId, statusId)); }
From source file:org.killbill.billing.plugin.meter.api.user.JsonSamplesOutputer.java
private void writeJsonForStoredChunks(final JsonGenerator generator, final List<Integer> hostIdsList, final List<Integer> sampleKindIdsList, final DateTime startTime, final DateTime endTime) throws IOException { final AtomicReference<Integer> lastHostId = new AtomicReference<Integer>(null); final AtomicReference<Integer> lastSampleKindId = new AtomicReference<Integer>(null); final List<TimelineChunk> chunksForHostAndSampleKind = new ArrayList<TimelineChunk>(); timelineDao.getSamplesBySourceIdsAndMetricIds(hostIdsList, sampleKindIdsList, startTime, endTime, new TimelineChunkConsumer() { @Override/*from w ww . j a v a 2 s. c o m*/ public void processTimelineChunk(final TimelineChunk chunks) { final Integer previousHostId = lastHostId.get(); final Integer previousSampleKindId = lastSampleKindId.get(); final Integer currentHostId = chunks.getSourceId(); final Integer currentSampleKindId = chunks.getMetricId(); chunksForHostAndSampleKind.add(chunks); if (previousHostId != null && (!previousHostId.equals(currentHostId) || !previousSampleKindId.equals(currentSampleKindId))) { try { writeJsonForChunks(generator, chunksForHostAndSampleKind); } catch (IOException e) { throw new RuntimeException(e); } chunksForHostAndSampleKind.clear(); } lastHostId.set(currentHostId); lastSampleKindId.set(currentSampleKindId); } }, context); if (chunksForHostAndSampleKind.size() > 0) { writeJsonForChunks(generator, chunksForHostAndSampleKind); chunksForHostAndSampleKind.clear(); } }
From source file:com.itjenny.web.ArticleController.java
@RequestMapping(value = "{title}", method = RequestMethod.GET) public ModelAndView getArticle(@PathVariable String title) { ModelAndView mav = new ModelAndView(); ModelMap model = new ModelMap(); Integer chapterIndex = bookmarkService.getChapterIndex(title); List<Chapter> chapters = articleService.getChaptersToIndex(title, chapterIndex); if (chapters == null) { logger.info("title({}) isn't existed", title); return new ModelAndView("redirect:/" + URL.ARTICLE); }//from w w w .ja v a 2s. co m model.addAttribute("title", title); model.addAttribute("chapters", chapters); model.addAttribute("license", chapterIndex.equals(Consts.BOOKMARK_LICENSE)); model.addAttribute("totalSection", articleService.getTotalSection(title)); model.addAttribute("setting", settingService.get(sessionService.getLoginUser().getUserId())); String css = articleService.get(title).getCss(); if (StringUtils.isEmpty(css)) { model.addAttribute("css", themeService.getDefault().getCss()); } else { model.addAttribute("css", css); } mav.setViewName(View.ARTICLE); mav.addAllObjects(model); bookmarkService.updateChapter(title, 0); return mav; }
From source file:me.azenet.UHPlugin.scoreboard.ScoreboardManager.java
/** * Updates the counters of the scoreboard (if needed). *///ww w.j a v a 2 s. c om public void updateCounters() { if (p.getConfig().getBoolean("scoreboard.enabled")) { Integer episode = gm.getEpisode(); Integer alivePlayersCount = gm.getAlivePlayersCount(); Integer aliveTeamsCount = gm.getAliveTeamsCount(); if (!episode.equals(oldEpisode) && p.getConfig().getBoolean("episodes.enabled") && p.getConfig().getBoolean("scoreboard.episode")) { if (oldEpisode == -1) oldEpisode = 0; // May happens the first time sidebar.updateEntry(getText("episode", oldEpisode), getText("episode", episode)); oldEpisode = episode; } if (!alivePlayersCount.equals(oldAlivePlayersCount) && p.getConfig().getBoolean("scoreboard.players")) { // Needed if the game is launched without any player, and players are marked as alive later. if (oldAlivePlayersCount == -1) oldAlivePlayersCount = 0; sidebar.updateEntry(getText("players", oldAlivePlayersCount), getText("players", alivePlayersCount)); oldAlivePlayersCount = alivePlayersCount; } if (gm.isGameWithTeams() && !aliveTeamsCount.equals(oldAliveTeamsCount) && p.getConfig().getBoolean("scoreboard.teams")) { // Needed if the game is launched without any player, and players are marked as alive later. if (oldAliveTeamsCount == -1) oldAliveTeamsCount = 0; sidebar.updateEntry(getText("teams", oldAliveTeamsCount), getText("teams", aliveTeamsCount)); oldAliveTeamsCount = aliveTeamsCount; } } }
From source file:com.aurel.track.fieldType.bulkSetters.ItemPickerBulkSetter.java
/** * Sets the workItemBean's attribute depending on the value and bulkRelation * @param workItemBean/*ww w. ja v a 2 s . c om*/ * @param fieldID * @param parameterCode * @param bulkTranformContext * @param selectContext * @param value * @return ErrorData if an error is found */ @Override public ErrorData setWorkItemAttribute(TWorkItemBean workItemBean, Integer fieldID, Integer parameterCode, BulkTranformContext bulkTranformContext, SelectContext selectContext, Object value) { Integer itemID = null; try { itemID = (Integer) value; } catch (Exception e) { LOGGER.info("Getting the string value for " + value + " failed with " + e.getMessage()); LOGGER.debug(ExceptionUtils.getStackTrace(e)); } switch (getRelation()) { case BulkRelations.SET_TO: if (itemID != null) { if (itemID.equals(workItemBean.getObjectID())) { return new ErrorData("itemov.massOperation.err.parentIsDescendant"); } else { workItemBean.setAttribute(fieldID, parameterCode, new Object[] { itemID }); } } break; case BulkRelations.ADD_ITEMS: if (itemID != null) { if (itemID.equals(workItemBean.getObjectID())) { return new ErrorData("itemov.massOperation.err.recursiveItemPicker"); } else { Object[] actualValue = (Object[]) workItemBean.getAttribute(fieldID); Object[] newValue = addItem(actualValue, itemID); workItemBean.setAttribute(fieldID, parameterCode, newValue); } } break; case BulkRelations.REMOVE_ITEMS: if (itemID != null) { Object[] actualValue = (Object[]) workItemBean.getAttribute(fieldID); Object[] newValue = removeItem(actualValue, itemID); workItemBean.setAttribute(fieldID, parameterCode, newValue); } break; case BulkRelations.SET_NULL: workItemBean.setAttribute(fieldID, parameterCode, null); break; } //no error return null; }
From source file:de.iteratec.iteraplan.model.BusinessMapping.java
public boolean equalsIds(Integer bpID, Integer ouID, Integer prId) { boolean isAnyParameterNull = bpID == null || ouID == null || prId == null; boolean isAnyReferenceNull = businessProcess == null || businessUnit == null || product == null; if (isAnyParameterNull || isAnyReferenceNull) { return false; }/* w w w .j a v a 2s . com*/ if (bpID.equals(businessProcess.getId()) && ouID.equals(businessUnit.getId()) && prId.equals(product.getId())) { return true; } return false; }
From source file:com.snapdeal.archive.service.impl.ArchivalServiceImpl.java
private boolean checkForEquality(Object childObject, Object parentObject, String columnType) { Boolean isEquals = Boolean.FALSE; switch (columnType) { case "Integer": Integer childVal = (Integer) childObject; Integer parentVal = (Integer) parentObject; isEquals = childVal.equals(parentVal); break;/*w w w. j a va 2 s .co m*/ case "String": String childValStr = (String) childObject; String parentValStr = (String) parentObject; isEquals = childValStr.equals(parentValStr); break; case "Long": Long childValLong = (Long) childObject; Long parentValLong = (Long) parentObject; isEquals = childValLong.equals(parentValLong); break; } return isEquals; }
From source file:com.thinkbiganalytics.discovery.parsers.csv.CSVAutoDetect.java
private Character guessDelimiter(List<LineStats> lineStats, String value, Character quote, boolean headerRow) throws IOException { // Assume delimiter exists in first line and compare to subsequent lines if (lineStats.size() > 0) { LineStats firstLineStat = lineStats.get(0); Map<Character, Integer> firstLineDelimCounts = firstLineStat.calcDelimCountsOrdered(); if (firstLineDelimCounts != null && firstLineDelimCounts.size() > 0) { List<Character> candidates = new ArrayList<>(); // Attempt to parse given delimiter Set<Character> firstLineDelimKeys = firstLineDelimCounts.keySet(); for (Character delim : firstLineDelimKeys) { CSVFormat format;//from w ww. j a va2s . c om if (headerRow) { format = CSVFormat.DEFAULT.withFirstRecordAsHeader().withDelimiter(delim).withQuote(quote); } else { format = CSVFormat.DEFAULT.withDelimiter(delim).withQuote(quote); } try (StringReader sr = new StringReader(value)) { try (CSVParser parser = format.parse(sr)) { if (parser.getHeaderMap() != null) { int size = parser.getHeaderMap().size(); List<CSVRecord> records = parser.getRecords(); boolean match = records.stream().allMatch(record -> record.size() == size); if (match) { return delim; } } } } Integer delimCount = firstLineDelimCounts.get(delim); boolean match = true; for (int i = 1; i < lineStats.size() && match; i++) { LineStats thisLine = lineStats.get(i); Integer rowDelimCount = thisLine.delimStats.get(delim); match = delimCount.equals(rowDelimCount); } if (match) { candidates.add(delim); } } if (candidates.size() > 0) { // All agree on a single delimiter if (candidates.size() == 1) { return candidates.get(0); } else { int count = 0; // Return highest delimiter from candidates for (Character delim : firstLineDelimKeys) { if (candidates.get(count++) != null) { return delim; } } } } } } return null; }
From source file:com.apptentive.android.sdk.Apptentive.java
private static void init(Activity activity) { ////w ww. j a v a 2s .c om // First, initialize data relies on synchronous reads from local resources. // final Context appContext = activity.getApplicationContext(); if (!GlobalInfo.initialized) { SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); // First, Get the api key, and figure out if app is debuggable. GlobalInfo.isAppDebuggable = false; String apiKey = null; boolean apptentiveDebug = false; String logLevelOverride = null; try { ApplicationInfo ai = appContext.getPackageManager().getApplicationInfo(appContext.getPackageName(), PackageManager.GET_META_DATA); Bundle metaData = ai.metaData; if (metaData != null) { apiKey = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_API_KEY); logLevelOverride = metaData.getString(Constants.MANIFEST_KEY_APPTENTIVE_LOG_LEVEL); apptentiveDebug = metaData.getBoolean(Constants.MANIFEST_KEY_APPTENTIVE_DEBUG); ApptentiveClient.useStagingServer = metaData .getBoolean(Constants.MANIFEST_KEY_USE_STAGING_SERVER); } if (apptentiveDebug) { Log.i("Apptentive debug logging set to VERBOSE."); ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE); } else if (logLevelOverride != null) { Log.i("Overriding log level: %s", logLevelOverride); ApptentiveInternal.setMinimumLogLevel(Log.Level.parse(logLevelOverride)); } else { GlobalInfo.isAppDebuggable = (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; if (GlobalInfo.isAppDebuggable) { ApptentiveInternal.setMinimumLogLevel(Log.Level.VERBOSE); } } } catch (Exception e) { Log.e("Unexpected error while reading application info.", e); } Log.i("Debug mode enabled? %b", GlobalInfo.isAppDebuggable); // If we are in debug mode, but no api key is found, throw an exception. Otherwise, just assert log. We don't want to crash a production app. String errorString = "No Apptentive api key specified. Please make sure you have specified your api key in your AndroidManifest.xml"; if ((Util.isEmpty(apiKey))) { if (GlobalInfo.isAppDebuggable) { AlertDialog alertDialog = new AlertDialog.Builder(activity).setTitle("Error") .setMessage(errorString).setPositiveButton("OK", null).create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } Log.e(errorString); } GlobalInfo.apiKey = apiKey; Log.i("API Key: %s", GlobalInfo.apiKey); // Grab app info we need to access later on. GlobalInfo.appPackage = appContext.getPackageName(); GlobalInfo.androidId = Settings.Secure.getString(appContext.getContentResolver(), android.provider.Settings.Secure.ANDROID_ID); // Check the host app version, and notify modules if it's changed. try { PackageManager packageManager = appContext.getPackageManager(); PackageInfo packageInfo = packageManager.getPackageInfo(appContext.getPackageName(), 0); Integer currentVersionCode = packageInfo.versionCode; String currentVersionName = packageInfo.versionName; VersionHistoryStore.VersionHistoryEntry lastVersionEntrySeen = VersionHistoryStore .getLastVersionSeen(appContext); if (lastVersionEntrySeen == null) { onVersionChanged(appContext, null, currentVersionCode, null, currentVersionName); } else { if (!currentVersionCode.equals(lastVersionEntrySeen.versionCode) || !currentVersionName.equals(lastVersionEntrySeen.versionName)) { onVersionChanged(appContext, lastVersionEntrySeen.versionCode, currentVersionCode, lastVersionEntrySeen.versionName, currentVersionName); } } GlobalInfo.appDisplayName = packageManager .getApplicationLabel(packageManager.getApplicationInfo(packageInfo.packageName, 0)) .toString(); } catch (PackageManager.NameNotFoundException e) { // Nothing we can do then. GlobalInfo.appDisplayName = "this app"; } // Grab the conversation token from shared preferences. if (prefs.contains(Constants.PREF_KEY_CONVERSATION_TOKEN) && prefs.contains(Constants.PREF_KEY_PERSON_ID)) { GlobalInfo.conversationToken = prefs.getString(Constants.PREF_KEY_CONVERSATION_TOKEN, null); GlobalInfo.personId = prefs.getString(Constants.PREF_KEY_PERSON_ID, null); } GlobalInfo.initialized = true; Log.v("Done initializing..."); } else { Log.v("Already initialized..."); } // Initialize the Conversation Token, or fetch if needed. Fetch config it the token is available. if (GlobalInfo.conversationToken == null || GlobalInfo.personId == null) { asyncFetchConversationToken(appContext.getApplicationContext()); } else { asyncFetchAppConfiguration(appContext.getApplicationContext()); InteractionManager.asyncFetchAndStoreInteractions(appContext.getApplicationContext()); } // TODO: Do this on a dedicated thread if it takes too long. Some devices are slow to read device data. syncDevice(appContext); syncSdk(appContext); syncPerson(appContext); Log.d("Default Locale: %s", Locale.getDefault().toString()); SharedPreferences prefs = appContext.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); Log.d("Conversation id: %s", prefs.getString(Constants.PREF_KEY_CONVERSATION_ID, "null")); }