Example usage for java.lang Integer equals

List of usage examples for java.lang Integer equals

Introduction

In this page you can find the example usage for java.lang Integer equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:gov.nih.nci.ncicb.tcga.dcc.common.util.CommonBarcodeAndUUIDValidatorImpl.java

/**
 * Return <code>true</code> if the portion number and the slide number are equivalent, <code>false</code> otherwise:
 * <p/>//  ww  w  .jav  a2  s.c o  m
 * 1 === 1 or 1 === A
 * 2 === 2 or 2 === B
 * 3 === 3 or 3 === C
 * etc ...
 *
 * @param portionNumber the portion number
 * @param slideNumber   the slide number
 * @return <code>true</code> if the portion number and the slide number are equivalent, <code>false</code> otherwise
 */
private boolean isEquivalentNumber(final String portionNumber, final String slideNumber) {

    final Integer portionNumberAsInteger = getInteger(portionNumber);
    final Integer slideNumberAsInteger = getInteger(slideNumber);
    boolean result = portionNumberAsInteger != null && portionNumberAsInteger.equals(slideNumberAsInteger);

    return result;
}

From source file:com.evolveum.midpoint.task.quartzimpl.work.WorkStateManager.java

private void setOrUpdateEstimatedNumberOfBuckets(Task task, WorkSegmentationStrategy workStateStrategy,
        OperationResult result) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException {
    Integer number = workStateStrategy.estimateNumberOfBuckets(task.getWorkState());
    if (number != null
            && (task.getWorkState() == null || !number.equals(task.getWorkState().getNumberOfBuckets()))) {
        List<ItemDelta<?, ?>> itemDeltas = DeltaBuilder.deltaFor(TaskType.class, prismContext)
                .item(TaskType.F_WORK_STATE, TaskWorkStateType.F_NUMBER_OF_BUCKETS).replace(number)
                .asItemDeltas();/*w w  w .  j av  a 2  s. c  o m*/
        repositoryService.modifyObject(TaskType.class, task.getOid(), itemDeltas, result);
    }
}

From source file:org.sakaiproject.lessonbuildertool.service.AjaxServer.java

public static String filterHtml(String contents) {

    StringBuilder error = new StringBuilder();

    final Integer FILTER_DEFAULT = 0;
    final Integer FILTER_HIGH = 1;
    final Integer FILTER_LOW = 2;
    final Integer FILTER_NONE = 3;

    // Sakai currently defaults to high. Unfortunately many
    // embeds won't work with that. Might want to default this
    // to low, or add another config parameter, but currently
    // using same code as for text blocks.

    String html = contents;// w  ww . j a  v a  2s  . c om

    // figure out how to filter
    Integer filter = FILTER_DEFAULT;
    // simplepagebean checks filterHtml property of tool. We can't really do that.

    String filterSpec = filterHtml;
    System.out.println("filterspec " + filterSpec);
    if (filterSpec == null) // should never be null. unspeciifed should give ""
        filter = FILTER_DEFAULT;
    // old specifications
    else if (filterSpec.equalsIgnoreCase("true"))
        filter = FILTER_HIGH; // old value of true produced the same result as missing
    else if (filterSpec.equalsIgnoreCase("false"))
        filter = FILTER_NONE;
    // new ones
    else if (filterSpec.equalsIgnoreCase("default"))
        filter = FILTER_DEFAULT;
    else if (filterSpec.equalsIgnoreCase("high"))
        filter = FILTER_HIGH;
    else if (filterSpec.equalsIgnoreCase("low"))
        filter = FILTER_LOW;
    else if (filterSpec.equalsIgnoreCase("none"))
        filter = FILTER_NONE;
    // unspecified
    else
        filter = FILTER_DEFAULT;

    if (filter.equals(FILTER_NONE)) {
        html = FormattedText.processHtmlDocument(contents, error);
    } else if (filter.equals(FILTER_DEFAULT)) {
        html = FormattedText.processFormattedText(contents, error);
    } else if (ftInstance != null) {
        try {
            // now filter is set. Implement it. Depends upon whether we have the anti-samy code
            Object level = null;
            if (filter.equals(FILTER_HIGH))
                level = levels[1];
            else
                level = levels[2];

            html = (String) ftMethod.invoke(ftInstance, new Object[] { contents, error, level });
        } catch (Exception e) {
            // this should never happen. If it does, emulate what the anti-samy
            // code does if antisamy is disabled. It always filters
            html = FormattedText.processFormattedText(contents, error);
        }
    } else {
        // don't have antisamy. For LOW, use old instructor behavior, since
        // LOW is the default. For high, it makes sense to filter
        if (filter.equals(FILTER_HIGH))
            html = FormattedText.processFormattedText(contents, error);
        else
            html = FormattedText.processHtmlDocument(contents, error);

    }
    return html;
}

From source file:nya.miku.wishmaster.chans.makaba.MakabaModule.java

@Override
public PostModel[] getPostsList(String boardName, String threadNumber, ProgressListener listener,
        CancellableTask task, PostModel[] oldList) throws Exception {
    boolean mobileAPI = preferences.getBoolean(getSharedKey(PREF_KEY_MOBILE_API), true);
    if (!mobileAPI) {
        String url = domainUrl + boardName + "/res/" + threadNumber + ".json";
        JSONObject object = downloadJSONObject(url, (oldList != null), listener, task);
        if (object == null)
            return oldList;
        JSONArray postsArray = object.getJSONArray("threads").getJSONObject(0).getJSONArray("posts");
        PostModel[] posts = new PostModel[postsArray.length()];
        for (int i = 0; i < postsArray.length(); ++i) {
            posts[i] = mapPostModel(postsArray.getJSONObject(i), boardName);
        }//  www . j  av a 2  s.  c  o  m
        if (oldList != null) {
            posts = ChanModels.mergePostsLists(Arrays.asList(oldList), Arrays.asList(posts));
        }
        return posts;
    }
    try {
        String lastPost = threadNumber;
        if (oldList != null && oldList.length > 0) {
            lastPost = oldList[oldList.length - 1].number;
        }
        String url = domainUrl + "makaba/mobile.fcgi?task=get_thread&board=" + boardName + "&thread="
                + threadNumber + "&num=" + lastPost;
        JSONArray newPostsArray = downloadJSONArray(url, (oldList != null), listener, task);
        if (newPostsArray == null)
            return oldList;
        PostModel[] newPosts = new PostModel[newPostsArray.length()];
        for (int i = 0; i < newPostsArray.length(); ++i) {
            newPosts[i] = mapPostModel(newPostsArray.getJSONObject(i), boardName);
        }
        if (oldList == null || oldList.length == 0) {
            return newPosts;
        } else {
            long lastNum = Long.parseLong(lastPost);
            ArrayList<PostModel> list = new ArrayList<PostModel>(Arrays.asList(oldList));
            for (int i = 0; i < newPosts.length; ++i) {
                if (Long.parseLong(newPosts[i].number) > lastNum) {
                    list.add(newPosts[i]);
                }
            }
            return list.toArray(new PostModel[list.size()]);
        }
    } catch (JSONException e) {
        String lastPost = threadNumber;
        if (oldList != null && oldList.length > 0) {
            lastPost = oldList[oldList.length - 1].number;
        }
        String url = domainUrl + "makaba/mobile.fcgi?task=get_thread&board=" + boardName + "&thread="
                + threadNumber + "&num=" + lastPost;
        JSONObject makabaError = downloadJSONObject(url, (oldList != null), listener, task);
        Integer code = makabaError.has("Code") ? makabaError.getInt("Code") : null;
        if (code != null && code.equals(Integer.valueOf(-404)))
            code = 404;
        String error = code != null ? code.toString() : null;
        String reason = makabaError.has("Error") ? makabaError.getString("Error") : null;
        if (reason != null) {
            if (error != null) {
                error += ": " + reason;
            } else {
                error = reason;
            }
        }
        throw error == null ? e : new Exception(error);
    }
}

From source file:com.qcadoo.mes.productionScheduling.listeners.OrderTimePredictionListeners.java

private void scheduleOperationComponents(final Long technologyId, final Date startDate) {
    Entity technology = dataDefinitionService
            .get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY)
            .get(technologyId);//w w w .  ja  v  a  2  s  .  co m

    if (technology == null) {
        return;
    }

    DataDefinition technologyOperationComponentDD = dataDefinitionService.get(
            TechnologiesConstants.PLUGIN_IDENTIFIER,
            TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT);

    List<Entity> operations = technologyOperationComponentDD.find()
            .add(SearchRestrictions.belongsTo(TechnologiesConstants.MODEL_TECHNOLOGY, technology)).list()
            .getEntities();

    for (Entity operation : operations) {
        Entity techOperCompTimeCalculation = operation
                .getBelongsToField(TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_TIME_CALCULATION);

        if (techOperCompTimeCalculation == null) {
            continue;
        }

        Integer offset = (Integer) techOperCompTimeCalculation
                .getField(TechOperCompTimeCalculationsFields.OPERATION_OFF_SET);
        Integer duration = (Integer) techOperCompTimeCalculation
                .getField(TechOperCompTimeCalculationsFields.EFFECTIVE_OPERATION_REALIZATION_TIME);

        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_FROM, null);
        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_TO, null);

        if (offset == null || duration == null) {
            continue;
        }
        if (duration.equals(0)) {
            duration = duration + 1;
        }

        Date dateFrom = shiftsService.findDateToForOrder(startDate, offset);
        if (dateFrom == null) {
            continue;
        }

        Date dateTo = shiftsService.findDateToForOrder(startDate, offset + duration);
        if (dateTo == null) {
            continue;
        }

        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_FROM, dateFrom);
        techOperCompTimeCalculation.setField(TechOperCompTimeCalculationsFields.EFFECTIVE_DATE_TO, dateTo);

        techOperCompTimeCalculation.getDataDefinition().save(techOperCompTimeCalculation);
    }
}

From source file:com.nec.harvest.controller.UriageController.java

/**
 * This function will be mapped with URL {@link /uriage/save/{organizationCode}
 * /{businessDay}}, it can be used to save sales data changed. 
 * Will be displayed a message when have a exception or an error
 * occurred.//from  ww w .  java 2  s  .com
 * @param orgCode
 * @param monthly
 * @param params
 * @param model
 * @return JSonBean
 */
@RequestMapping(value = "/save/{orgCode:[a-z0-9]+}/{monthly:[\\d]+}", method = RequestMethod.POST, consumes = "application/json")
public @ResponseBody JSONBean saveUriageData(@UserPrincipal User user, @PathVariable String proGNo,
        @PathVariable String orgCode, @PathVariable @MaskFormat("######") String monthly,
        @RequestBody final JSONSales jSONSales, final Model model) {
    if (logger.isDebugEnabled()) {
        logger.debug("Saving sales data on month: " + monthly + " of organizetion code: " + orgCode);
    }

    String version = "";
    try {
        version = ProductHelper.getProductInfor().getVersion();
    } catch (IOException ex) {
        logger.warn(ex.getMessage());
    }

    List<SalesChange> salesChanges = null;
    try {
        salesChanges = (List<SalesChange>) salesChangeService.findByOrgCodeAndMonth(orgCode, monthly, true);
    } catch (IllegalArgumentException | ObjectNotFoundException ex) {
        logger.warn(ex.getMessage());

    } catch (TooManyObjectsException | ServiceException ex) {
        logger.error(ex.getMessage(), ex);

        // ???????????
        return new JSONBean(Boolean.FALSE, "", getSystemError());
    }

    String userCode = user.getUsrCode();
    List<SalesChange> salesChangeUpdLst = new ArrayList<SalesChange>();
    JSONSalesChange[] salesChangeUpds = jSONSales.getSalesChangeDatas();
    boolean isUpdated = false;
    Date curDate = new Date();
    Calendar calendar = GregorianCalendar.getInstance();
    calendar.setTime(curDate);
    for (int i = 0; i < salesChanges.size(); i++) {
        SalesChange salesChange = salesChanges.get(i);
        JSONSalesChange salesChangeUpd = salesChangeUpds[i];
        Integer updNoOld = salesChangeUpd.getUpdNo();
        Integer updNoNew = salesChange.getUpdNo();
        if (updNoOld == null && updNoNew == null) {
            isUpdated = true;
            updNoNew = 0;
        } else if (updNoOld.equals(updNoNew)) {
            isUpdated = true;
        } else {
            isUpdated = false;
        }
        if (isUpdated) {
            salesChange
                    .setGenkinUri(salesChangeUpd.getGenkinUri() != null ? salesChangeUpd.getGenkinUri() : 0D);
            salesChange.setZatsuUri(salesChangeUpd.getZatsuUri() != null ? salesChangeUpd.getZatsuUri() : 0D);
            salesChange.setKaisyuKG(salesChangeUpd.getKaisyuKG() != null ? salesChangeUpd.getKaisyuKG() : 0D);
            salesChange.setRem(salesChangeUpd.getRem());
            salesChange.setUriageKeijo1(
                    salesChangeUpd.getUriageKeijo1() != null ? salesChangeUpd.getUriageKeijo1() : 0D);
            salesChange.setUriageKeijo2(
                    salesChangeUpd.getUriageKeijo2() != null ? salesChangeUpd.getUriageKeijo2() : 0D);
            salesChange.setUriageKeijo3(
                    salesChangeUpd.getUriageKeijo3() != null ? salesChangeUpd.getUriageKeijo3() : 0D);
            salesChange.setShokenUrikake(
                    salesChangeUpd.getShokenUrikake() != null ? salesChangeUpd.getShokenUrikake() : 0D);
            salesChange.setUpdNo(updNoNew + 1);
            salesChange.setTanCode(userCode);
            salesChange.setAPInf2(userCode);
            salesChange.setStfCodeU(userCode);
            salesChange.setPrdNoU(version);
            salesChange.setTimeU(calendar);
            salesChangeUpdLst.add(salesChange);
        } else {
            return new JSONBean(Boolean.FALSE, "", MessageHelper.get(MsgConstants.CM_UPD_M01));
        }
    }

    boolean actualUpdateState = salesChangeService.updateSalesChanges(salesChanges);
    if (!actualUpdateState) {
        return new JSONBean(Boolean.FALSE, "", MessageHelper.get(MsgConstants.CM_UPD_M03));
    }

    SalesFixed salesFixedObj = salesFixedService.findByOrgCodeAndMonth(orgCode, monthly, true);
    if (salesFixedObj != null) {
        JSONSalesFixed salesFixedUpd = jSONSales.getSalesFixedData();
        Integer updNoOld = salesFixedObj.getUpdNo();
        Integer updNoNew = salesFixedUpd.getUpdNo();
        if (updNoOld == null && updNoNew == null) {
            isUpdated = true;
            updNoNew = 0;
        } else if (updNoOld.equals(updNoNew)) {
            isUpdated = true;
        } else {
            isUpdated = false;
        }
        if (isUpdated) {
            salesFixedObj.setKanrihi1(salesFixedUpd.getKanrihi1() != null ? salesFixedUpd.getKanrihi1() : 0D);
            salesFixedObj.setKanrihi2(salesFixedUpd.getKanrihi2() != null ? salesFixedUpd.getKanrihi2() : 0D);
            salesFixedObj.setKanrihi3(salesFixedUpd.getKanrihi3() != null ? salesFixedUpd.getKanrihi3() : 0D);
            salesFixedObj.setUrikakeSosai1(
                    salesFixedUpd.getUrikakeSosai1() != null ? salesFixedUpd.getUrikakeSosai1() : 0D);
            salesFixedObj.setUrikakeSosai2(
                    salesFixedUpd.getUrikakeSosai2() != null ? salesFixedUpd.getUrikakeSosai2() : 0D);
            salesFixedObj.setUrikakeSosai3(
                    salesFixedUpd.getUrikakeSosai3() != null ? salesFixedUpd.getUrikakeSosai3() : 0D);
            salesFixedObj.setUpdNo(updNoNew + 1);
            salesFixedObj.setTanCode(userCode);
            salesFixedObj.setAPInf2(userCode);
            salesFixedObj.setStfCodeU(userCode);
            salesFixedObj.setPrdNoU(version);
            salesFixedObj.setTimeU(calendar);
            salesFixedObj.setUpdID(curDate);
        } else {
            return new JSONBean(Boolean.FALSE, "", MessageHelper.get(MsgConstants.CM_UPD_M01));
        }

        actualUpdateState = salesFixedService.updateSalesFixeds(salesFixedObj);
        if (!actualUpdateState) {
            return new JSONBean(Boolean.FALSE, "", MessageHelper.get(MsgConstants.CM_UPD_M03));
        }
    }
    return new JSONBean(true, "", MessageHelper.get(MsgConstants.CM_UPD_M02));
}

From source file:com.abiquo.api.services.EnterpriseService.java

@Transactional(readOnly = false, propagation = Propagation.REQUIRED)
public Enterprise modifyEnterprise(final Integer enterpriseId, final EnterpriseDto dto) {
    Enterprise old = repo.findById(enterpriseId);
    if (old == null) {
        addNotFoundErrors(APIError.NON_EXISTENT_ENTERPRISE);
        flushErrors();/* w  w w. ja va 2 s  .com*/
    }

    Integer userEnt = userService.getCurrentUser().getEnterprise().getId();
    if (!securityService.hasPrivilege(Privileges.USERS_MANAGE_OTHER_ENTERPRISES)
            && !userEnt.equals(dto.getId())) {
        throw new AccessDeniedException("");
    }

    if (dto.getName().isEmpty()) {
        addValidationErrors(APIError.ENTERPRISE_EMPTY_NAME);
        flushErrors();
    }

    if (repo.existsAnyOtherWithName(old, dto.getName())) {
        addConflictErrors(APIError.ENTERPRISE_DUPLICATED_NAME);
        flushErrors();
    }

    old.setName(dto.getName());
    old.setIsReservationRestricted(dto.getIsReservationRestricted());
    old.setRamLimitsInMb(new Limit((long) dto.getRamSoftLimitInMb(), (long) dto.getRamHardLimitInMb()));
    old.setCpuCountLimits(new Limit((long) dto.getCpuCountSoftLimit(), (long) dto.getCpuCountHardLimit()));
    old.setHdLimitsInMb(new Limit(dto.getHdSoftLimitInMb(), dto.getHdHardLimitInMb()));
    old.setStorageLimits(new Limit(dto.getStorageSoft(), dto.getStorageHard()));
    old.setRepositoryLimits(new Limit(dto.getRepositorySoft(), dto.getRepositoryHard()));
    old.setVlansLimits(new Limit(dto.getVlansSoft(), dto.getVlansHard()));
    old.setPublicIPLimits(new Limit(dto.getPublicIpsSoft(), dto.getPublicIpsHard()));
    isValidEnterprise(old);
    isValidEnterpriseLimit(old);

    // if we are in community the Pricingtemplate id is not informed, is null
    // in this case we don't overwrite the old value.
    if (securityService.hasPrivilege(Privileges.PRICING_MANAGE)) {
        if (dto.searchLink(PricingTemplateResource.PRICING_TEMPLATE) != null) {
            int idPricing = getPricingTemplateId(dto);
            if (idPricing == 0) {
                old.setPricingTemplate(null);
            } else {

                PricingTemplate pricingTemplate = findPricingTemplate(idPricing);
                old.setPricingTemplate(pricingTemplate);
                tracer.log(SeverityType.INFO, ComponentType.ENTERPRISE, EventType.PRICING_TEMPLATE_ASSIGNED,
                        "pricingtemplate.assigned", pricingTemplate.getName(), old.getName());
            }
        }
    }

    repo.update(old);
    tracer.log(SeverityType.INFO, ComponentType.ENTERPRISE, EventType.ENTERPRISE_MODIFY, "enterprise.modified",
            old.getName());
    return old;
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.CompositeSelectMatcherRT.java

/**
 * Whether the value matches or not//w w w  .  j av  a2 s .  c o m
 * @param attributeValue
 * @return
 */
@Override
public boolean match(Object attributeValue) {
    Boolean nullMatch = nullMatcher(attributeValue);
    if (nullMatch != null) {
        return nullMatch.booleanValue();
    }
    if (attributeValue == null || matchValue == null) {
        return false;
    }
    Map<Integer, Object> attributeValueMap = null;
    try {
        attributeValueMap = (Map<Integer, Object>) attributeValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the attribute value of type " + attributeValue.getClass().getName()
                + " to Map<Integer, Object failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    SortedMap<Integer, Object> matcherValueMap = null;
    try {
        matcherValueMap = (SortedMap<Integer, Object>) matchValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the matcher value of type " + matchValue.getClass().getName()
                + " to SortedMap<Integer, Object> failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (attributeValueMap == null || matcherValueMap == null) {
        return false;
    }
    Iterator<Integer> iterator = matcherValueMap.keySet().iterator();
    while (iterator.hasNext()) {
        Integer parameterCode = iterator.next();
        Object[] attributeValueCustomOption = null;
        try {
            attributeValueCustomOption = (Object[]) attributeValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.warn("Converting the attribute value for part " + parameterCode + " to Object[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }
        Integer[] matcherValueCustomOption = null;
        try {
            matcherValueCustomOption = (Integer[]) matcherValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.error("Converting the matcher value for part " + parameterCode + " to Integer[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }

        if (attributeValueCustomOption == null) {
            attributeValueCustomOption = new Object[0];
        }
        if (matcherValueCustomOption == null) {
            matcherValueCustomOption = new Integer[0];
        }
        if (attributeValueCustomOption.length != matcherValueCustomOption.length) {
            return false;
        }

        if (matcherValueCustomOption.length == 0) {
            return matcherValueCustomOption.length == 0;
        }
        Integer matcherValueAtLevel = matcherValueCustomOption[0];
        switch (relation) {
        case MatchRelations.EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return false;
            }
            break;
        case MatchRelations.NOT_EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return true;
            }
            break;
        case MatchRelations.PARTIAL_MATCH:
            if (matcherValueAtLevel.equals(ANY_FROM_LEVEL)) {
                return true;
            } else {
                if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                    return false;
                }
            }
            break;
        case MatchRelations.PARTIAL_NOTMATCH:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)
                    && !matcherValueCustomOption[0].equals(NONE_FROM_LEVEL)) {
                return true;
            }
            break;
        default:
            return false;
        }
    }
    if (relation == MatchRelations.NOT_EQUAL || relation == MatchRelations.PARTIAL_NOTMATCH) {
        return false;
    } else {
        return true;
    }
}

From source file:com.bizintelapps.bugtracker.service.impl.ReportServiceImpl.java

/**
 * //from w  w w . j av  a2  s. c o  m
 * @param userId
 * @param ownerId
 * @param assignedBy
 * @param assignDate
 * @param eh
 */
private void removeTaskAssigned(Integer userId, Integer ownerId, Integer assignedBy, Date assignDate, double eh,
        boolean isDelete, double hoursSpend) {
    Calendar c = Calendar.getInstance();
    c.setTime(assignDate);
    UserReport userReport1 = userReportDao.findByUserMonthAndYear(userId, c.get(Calendar.MONTH),
            c.get(Calendar.YEAR));
    if (ownerId.equals(userId) && assignedBy.equals(userId)) {
        userReport1.setCreatedSelfAssigned(userReport1.getCreatedSelfAssigned() - 1);
    } else if (assignedBy.equals(userId)) {
        userReport1.setSelfAssigned(userReport1.getSelfAssigned() - 1);
    } else {
        userReport1.setAssigned(userReport1.getAssigned() - 1);
    }
    userReport1.setTotalAssigned(userReport1.getTotalAssigned() - 1);
    userReport1.setEstimatedHours(userReport1.getEstimatedHours() - eh);
    if (!isDelete) {
        userReport1.setHoursSpend(userReport1.getHoursSpend() - hoursSpend);
    }
    userReportDao.update(userReport1);
}

From source file:com.almende.eve.agent.google.GoogleCalendarAgent.java

/**
 * Delete an existing event./* w  w  w  .  ja v  a 2 s.  co m*/
 * 
 * @param eventId
 *            id of the event to be deleted
 * @param calendarId
 *            Optional calendar id. the primary calendar is used by default
 * @throws Exception
 *             the exception
 */
@Override
public void deleteEvent(@Name("eventId") final String eventId, @Optional @Name("calendarId") String calendarId)
        throws Exception {
    // initialize optional parameters
    if (calendarId == null) {
        calendarId = getState().get("email", String.class);
    }

    // built url
    final String url = CALENDAR_URI + calendarId + "/events/" + eventId;

    // perform POST request
    final Map<String, String> headers = getAuthorizationHeaders();
    final String resp = HttpUtil.delete(url, headers);
    if (!resp.isEmpty()) {
        final ObjectNode node = JOM.getInstance().readValue(resp, ObjectNode.class);

        // check error code
        if (node.has("error")) {
            final ObjectNode error = (ObjectNode) node.get("error");
            final Integer code = error.has("code") ? error.get("code").asInt() : null;
            if (code != null && (code.equals(404) || code.equals(410))) {
                throw new JSONRPCException(CODE.NOT_FOUND);
            }

            throw new JSONRPCException(error);
        } else {
            throw new Exception(resp);
        }
    }
}