Example usage for java.lang Long intValue

List of usage examples for java.lang Long intValue

Introduction

In this page you can find the example usage for java.lang Long intValue.

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Long as an int after a narrowing primitive conversion.

Usage

From source file:gr.abiss.calipso.hibernate.HibernateDao.java

@Override
public int loadCountOfRecordsHavingStatus(Space space, int status) {
    Criteria criteria = getSession().createCriteria(Item.class);
    criteria.add(Restrictions.eq("space", space));
    criteria.add(Restrictions.eq("status", status));
    criteria.setProjection(Projections.rowCount());
    Long itemCount = (Long) criteria.list().get(0);
    // even when no item has this status currently, items may have history with this status
    // because of the "parent" difference, cannot use AbstractItem and have to do a separate Criteria query
    criteria = getSession().createCriteria(History.class);
    criteria.createCriteria("parent").add(Restrictions.eq("space", space));
    criteria.add(Restrictions.eq("status", status));
    criteria.setProjection(Projections.rowCount());
    return itemCount.intValue() + ((Long) criteria.list().get(0)).intValue();
}

From source file:de.innovationgate.webgate.api.jdbc.WGDatabaseImpl.java

private TableGenerator getTableGenerator(String seqName, Long startValue)
        throws InstantiationException, IllegalAccessException {

    TableGenerator tg = _generatorCache.get(seqName);
    if (tg != null && (startValue == null || startValue.equals(tg.getInitialValue()))) {
        return tg;
    }//from   w  ww .java2s . c  o m

    Properties props = new Properties();
    props.put(TableGenerator.TABLE_PARAM, "cs_sequences");
    props.put(TableGenerator.SEGMENT_COLUMN_PARAM, "name");
    props.put(TableGenerator.SEGMENT_VALUE_PARAM, seqName);
    props.put(TableGenerator.VALUE_COLUMN_PARAM, "value");
    props.put(TableGenerator.OPT_PARAM, "none");
    props.put(TableGenerator.IDENTIFIER_NORMALIZER, _conf.createMappings().getObjectNameNormalizer());

    if (startValue != null) {
        props.put(TableGenerator.INITIAL_PARAM, startValue.intValue());
    }

    tg = TableGenerator.class.newInstance();

    Dialect dialect = ((SessionFactoryImplementor) _sessionFactory).getJdbcServices().getDialect();
    tg.configure(_sessionFactory.getTypeHelper().basic(Long.class), props, dialect);
    _generatorCache.put(seqName, tg);

    return tg;

}

From source file:de.juwimm.cms.remote.EditionServiceSpringImpl.java

/**
 * #################################################################################### S T E P 6 Reparse ViewComponents / Content for Internal Links, Pics, Docs
 * ####################################################################################
 *//*www . j a  va  2 s. c  om*/
private void reparseViewComponent(ViewComponentHbm vcl) throws Exception {
    // if (!context.getRollbackOnly()) {
    try {
        String ref = vcl.getReference();
        if (log.isDebugEnabled())
            log.debug("Reparsing VC: " + vcl.getDisplayLinkName());
        switch (vcl.getViewType()) {
        case Constants.VIEW_TYPE_EXTERNAL_LINK: // dont do anythink at the external link
        case Constants.VIEW_TYPE_SEPARATOR:
            break;
        case Constants.VIEW_TYPE_INTERNAL_LINK:
        case Constants.VIEW_TYPE_SYMLINK:
            String newRefId = ref;
            try {
                newRefId = mappingVCs.get(new Integer(ref)).toString();
            } catch (Exception exe) {
                log.warn("Error while changing ref: " + ref + " to " + newRefId + " : " + exe.getMessage());
            }
            vcl.setReference(newRefId);
            break;
        case Constants.VIEW_TYPE_CONTENT:
        case Constants.VIEW_TYPE_UNIT:
        default:
            if (log.isDebugEnabled())
                log.debug("Reparsing Content of VC to Ref: " + ref);
            if (ref != null && !ref.equalsIgnoreCase("") && !ref.equalsIgnoreCase("root")) {
                ContentHbm content = null;
                try {
                    content = getContentHbmDao().load(new Integer(ref));
                } catch (Exception e) {
                    log.warn("Cannot find referenced content " + ref + " - continue import");
                }
                if (content != null) {
                    Collection cvlColl = content.getContentVersions();
                    Iterator cvlIt = cvlColl.iterator();
                    while (cvlIt.hasNext()) {
                        ContentVersionHbm cvl = (ContentVersionHbm) cvlIt.next();
                        String text = cvl.getText();
                        if (text != null && !text.equalsIgnoreCase("")) {
                            org.w3c.dom.Document doc = null;
                            try {
                                InputSource in = new InputSource(new StringReader(text));
                                doc = XercesHelper.inputSource2Dom(in);
                            } catch (Exception exe) {
                            }
                            if (doc != null) {
                                if (log.isDebugEnabled())
                                    log.debug(
                                            "Found ContentVersion: " + cvl.getContentVersionId() + " with DOC");
                                Iterator itILinks = XercesHelper.findNodes(doc, "//internalLink/internalLink");
                                while (itILinks.hasNext()) {
                                    Element elm = (Element) itILinks.next();
                                    String oldId = elm.getAttribute("viewid");
                                    try {
                                        System.out.println("oldId " + oldId);
                                        String newId = mappingVCs.get(new Integer(oldId)).toString();
                                        elm.setAttribute("viewid", newId);
                                    } catch (Exception exe) {
                                    }
                                }
                                Iterator itPics = XercesHelper.findNodes(doc, "//image[@src]");
                                while (itPics.hasNext()) {
                                    Element elm = (Element) itPics.next();
                                    String oldId = elm.getAttribute("src");
                                    try {
                                        String newId = mappingPics.get(new Integer(oldId)).toString();
                                        if (log.isDebugEnabled())
                                            log.debug("newId " + newId);
                                        elm.setAttribute("src", newId);
                                        ((Element) elm.getParentNode()).setAttribute("description", newId);
                                    } catch (Exception exe) {
                                    }
                                }
                                Iterator itDocs = XercesHelper.findNodes(doc, "//documents/document");
                                while (itDocs.hasNext()) {
                                    Element elm = (Element) itDocs.next();
                                    String oldId = elm.getAttribute("src");
                                    try {
                                        String newId = mappingDocs.get(new Integer(oldId)).toString();
                                        elm.setAttribute("src", newId);
                                        content.setUpdateSearchIndex(true);
                                    } catch (Exception exe) {
                                    }
                                }
                                /*
                                 * Here the reparsing of the database components has to be called
                                 */
                                Iterator itAggregation = XercesHelper.findNodes(doc, "//aggregation//include");
                                while (itAggregation.hasNext()) {
                                    try {
                                        Element ndeInclude = (Element) itAggregation.next();
                                        String type = ndeInclude.getAttribute("type");
                                        Long id = new Long(ndeInclude.getAttribute("id"));

                                        if (type.equals("person")) {
                                            if (mappingPersons.containsKey(id)) {
                                                Long newId = mappingPersons.get(id);
                                                ndeInclude.setAttribute("id", newId.toString());
                                            }
                                        } else if (type.equals("address")) {
                                            if (mappingAddresses.containsKey(id)) {
                                                Long newId = mappingAddresses.get(id);
                                                ndeInclude.setAttribute("id", newId.toString());
                                            }
                                        } else if (type.equals("unit")) {
                                            // Unit hat Integer Primary Keys
                                            if (mappingUnits.containsKey(new Integer(id.intValue()))) {
                                                Integer newId = mappingUnits.get(new Integer(id.intValue()));
                                                ndeInclude.setAttribute("id", newId.toString());
                                            }
                                        } else if (type.equals("department")) {
                                            if (mappingDepartments.containsKey(id)) {
                                                Long newId = mappingDepartments.get(id);
                                                ndeInclude.setAttribute("id", newId.toString());
                                            }
                                        } else if (type.equals("talkTime")) {
                                            if (mappingTalktime.containsKey(id)) {
                                                Long newId = mappingTalktime.get(id);
                                                ndeInclude.setAttribute("id", newId.toString());
                                            }
                                        }
                                    } catch (Exception exe) {
                                        log.error("Error during the replacement of database components:", exe);
                                    }
                                }
                                // READY
                                text = XercesHelper.doc2String(doc);
                                cvl.setText(text);
                            }
                        }
                    }
                }
            }
            // children
            if (vcl.getFirstChild() != null) {
                reparseViewComponent(vcl.getFirstChild());
            }
            break;
        }
        // next
        if (vcl.getNextNode() != null) {
            reparseViewComponent(vcl.getNextNode());
        }
    } catch (Exception exe) {
        // context.setRollbackOnly();
        throw exe;
    }
    // }
}

From source file:com.hiperf.common.ui.server.storage.impl.PersistenceHelper.java

@Override
public NakedObjectsList getSortedCollection(String nakedObjectName, com.hiperf.common.ui.shared.util.Id id,
        String attributeName, String sortAttribute, Boolean asc, int page, int rowsPerPage,
        ObjectsToPersist toPersist) throws PersistenceException {
    EntityManager em = null;//from  ww w.  ja v a 2s  .  c  om
    TransactionContext tc = null;
    Map<com.hiperf.common.ui.shared.util.Id, INakedObject> res = new HashMap<com.hiperf.common.ui.shared.util.Id, INakedObject>();
    try {
        Map<Object, IdHolder> newIdByOldId = new HashMap<Object, IdHolder>();
        tc = createTransactionalContext();
        em = tc.getEm();
        ITransaction tx = tc.getTx();
        tx.begin();
        doPersist(toPersist, null, res, newIdByOldId, em, true, null);
        String jpql = "select count(*) from " + nakedObjectName + " o";
        String currentFilter = getIdClause(id, attributeName);
        jpql += " where " + currentFilter;
        Query q = em.createQuery(jpql);
        Long count = getCount(id, newIdByOldId, q);
        int lastTotal = rowsPerPage * (page - 1);
        if (count > 0 && count > lastTotal) {
            jpql = "select o from " + nakedObjectName + " o ";
            jpql += "where " + currentFilter;
            if (asc != null) {
                if (asc) {
                    jpql += " order by o." + sortAttribute + " asc";
                } else {
                    jpql += " order by o." + sortAttribute + " desc";
                }
            }
            q = em.createQuery(jpql);
            int i = 0;
            for (Object idObj : id.getFieldValues()) {
                if (id.isLocal() && newIdByOldId.containsKey(idObj))
                    q.setParameter("id" + i, newIdByOldId.get(idObj).getId());
                else
                    q.setParameter("id" + i, idObj);
            }
            q.setFirstResult(lastTotal);
            q.setMaxResults(rowsPerPage);

            List<INakedObject> list = q.getResultList();
            if (list != null && !list.isEmpty()) {
                String name = list.get(0).getClass().getName();
                Map<String, Map<Object, Object>> oldIdByNewIdMap = buildInverseIdMap(newIdByOldId);
                list = deproxyEntities(name, list, true, oldIdByNewIdMap);
            }
            NakedObjectsList l = new NakedObjectsList(list, count.intValue(), rowsPerPage, currentFilter);
            l.setConstantFilterFields(new String[] { attributeName });
            return l;
        } else
            return null;
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Exception in getCollection " + e.getMessage(), e);
        throw new PersistenceException("Exception in getCollection " + e.getMessage(), e);
    } finally {
        finalizeTx(tc);
    }
}

From source file:com.youanmi.scrm.smp.facade.org.OrgInfoFacade.java

/**
 * /*  www.  ja v a  2 s .c  om*/
 * 
 * 
 * @param param ?
 */
public void orgDetailEdit(OrgDetailParam param) {
    Long currentTimeStamp = System.currentTimeMillis();

    // Long orgId = param.getOrgId();
    Long topOrgId = UserTokenThreadLocal.get().getTopOrgId();
    Long orgId = UserTokenThreadLocal.get().getOrgId();
    String name = param.getName();
    Long provinceId = param.getProvinceId();
    Long cityId = param.getCityId();
    Long areaId = param.getAreaId();
    String address = param.getAddress();
    String businessLicense = param.getBusinessLicense(); // ?
    Long parentOrgId = param.getParentOrgId(); // id
    // 1.
    if (orgId == null) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "id");
    }
    if (StringUtils.isBlank(name)) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "??");
    }
    if (StringUtils.isBlank(businessLicense)) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "??");
    }
    if (provinceId == null) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "?");
    }
    if (cityId == null) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "");
    }
    if (areaId == null) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "");
    }
    if (StringUtils.isBlank(address)) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "?");
    }

    if (parentOrgId == null) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_NOT_NULL, "");
    }

    // ???
    if (!MatcherUtils.matcherString(businessLicense, "^[0-9a-zA-Z\\S]+$")) {
        throw new ViewExternalDisplayException(ResultCode.orgDetail.BUSINESS_LICENSE_ILLEGAL);
    }
    // ??50
    if (address.length() > AccountTableConstants.Org.MAX_DETAIL_ADDRESS_LENGTH) {
        throw new ViewExternalDisplayException(ResultCode.System.PARAMETER_LENGTH_BEYOND, "?");
    }

    // ?
    Byte orgChildOrgType = orgInfoService.getOrgChildOrgType(parentOrgId);
    if (null != orgChildOrgType && orgChildOrgType.equals(AccountTableConstants.Org.ORG_TYPE_CHAIN_DEPART)) {
        throw new ViewExternalDisplayException(ResultCode.Org.DIRECT_ORG_HAS_DEPART);
    }

    // ???
    Long parentTopOrgId = null;
    OrgInfoDto parentOrgInfoDto = orgInfoService.getOrgById(parentOrgId);
    if (parentOrgInfoDto != null) {
        parentTopOrgId = parentOrgInfoDto.getTopOrgId();
    }

    if (!topOrgId.equals(parentTopOrgId)) {
        throw new ViewExternalDisplayException(ResultCode.System.ILLEGALITY_REQUEST);
    }

    // ??????
    boolean flag = uniqueneShopOrgName(name, orgId, topOrgId);
    if (!flag) {
        throw new ViewExternalDisplayException(ResultCode.Org.ORG_NAME_REPEAT);
    }
    //checkOrgName(orgId, name);

    // 2.?
    OrgDetailInfoDto dto = new OrgDetailInfoDto();
    dto.setOrgId(orgId);
    dto.setProvinceId(provinceId);
    dto.setCityId(cityId);
    dto.setAreaId(areaId);
    dto.setAddress(address);
    dto.setBusinessLicense(businessLicense);

    String provinceName = null;
    GeogProvincePo provincePo = geogProvinceService.selectByPrimaryKey(provinceId.intValue());
    if (provincePo != null) {
        provinceName = provincePo.getName();
        dto.setProvinceName(provinceName);
    }

    String cityName = null;
    GeogCityPo cityPo = geogCityService.selectByPrimaryKey(cityId.intValue());
    if (cityPo != null) {
        cityName = cityPo.getName();
        dto.setCityName(cityName);
    }

    String areaName = null;
    GeogAreaPo areaPo = geogAreaService.selectByPrimaryKey(areaId.intValue());
    if (areaPo != null) {
        areaName = areaPo.getName();
        dto.setAreaName(areaName);
    }

    // ????
    if (StringUtils.isBlank(provinceName) || StringUtils.isBlank(cityName) || StringUtils.isBlank(areaName)) {
        throw new ViewExternalDisplayException(ResultCode.System.ILLEGALITY_REQUEST);
    }

    dto.setUpdateTime(currentTimeStamp);
    orgDetailInfoService.updateByParam(dto);

    // 3.org
    OrgInfoDto updateOrgInfoDto = new OrgInfoDto();
    updateOrgInfoDto.setId(orgId);
    updateOrgInfoDto.setOrgName(name);
    updateOrgInfoDto.setParentOrgId(parentOrgId);
    updateOrgInfoDto.setUpdateTime(currentTimeStamp);
    orgInfoService.updateByPrimaryKeySelective(updateOrgInfoDto);

}

From source file:com.aimluck.eip.schedule.util.ScheduleUtils.java

protected static List<VEipTScheduleList> getScheduleList(int userId, Date viewStart, Date viewEnd,
        List<Integer> users, List<Integer> facilities, String keyword, int page, int limit, boolean isSearch,
        boolean isDetail, boolean auth) {

    boolean isMySQL = Database.isJdbcMySQL();

    StringBuilder select = new StringBuilder();

    select.append("select");
    if (!isSearch) {
        select.append(" t3.id, ");
        select.append(" t3.user_id, ");
        select.append(" t3.status, ");
        select.append(" t3.type, ");
        select.append(" t3.common_category_id, ");
    }//from  ww w. java 2  s .  co  m
    select.append(" t4.schedule_id,");
    select.append(" t4.owner_id,");
    select.append(" t4.parent_id,");
    select.append(" t4.name,");
    select.append(" t4.place,");
    select.append(" t4.start_date,");
    select.append(" t4.end_date,");
    select.append(" t4.update_date,");
    select.append(" t4.public_flag,");
    select.append(" t4.repeat_pattern,");
    select.append(" t4.create_user_id,");
    select.append(" t4.edit_flag,");
    if (isDetail) {
        select.append(" t4.note,");
    }
    select.append(
            " (SELECT COUNT(*) FROM eip_t_schedule_map t0 WHERE (t0.schedule_id = t4.schedule_id) AND (t0.user_id = #bind($user_id)) AND (t0.type = 'U')) AS is_member,");
    select.append(
            " (SELECT COUNT(*) FROM eip_t_schedule_map t1 WHERE (t1.schedule_id = t4.schedule_id) AND (t1.status <> 'R') AND (t1.type = 'F')) AS f_count,");
    select.append(
            " (SELECT COUNT(*) FROM eip_t_schedule_map t2 WHERE (t2.schedule_id = t4.schedule_id) AND (t2.status <> 'R') AND (t2.type <> 'F')) AS u_count");

    StringBuilder count = new StringBuilder();
    count.append("select count(t4.schedule_id) AS c ");

    boolean hasKeyword = false;
    StringBuilder body = new StringBuilder();
    if (isSearch) {
        body.append(" FROM eip_t_schedule t4 ");
        body.append(" WHERE ");
        body.append(" EXISTS ( ");
        body.append(
                " SELECT NULL FROM eip_t_schedule_map t3 WHERE t3.schedule_id = t4.schedule_id AND t3.status NOT IN('D', 'R') ");
        if (!auth) {
            body.append(" AND t3.user_id = #bind($user_id) AND t3.type = 'U' ");
        }
        if ((users != null && users.size() > 0) || (facilities != null && facilities.size() > 0)) {
            body.append(" AND (t3.type, t3.user_id) IN ( ");
            boolean isFirst = true;
            if (users != null && users.size() > 0) {
                for (Integer num : users) {
                    if (!isFirst) {
                        body.append(",");
                    }
                    body.append(" ('U', ");
                    body.append(num.intValue());
                    body.append(" ) ");
                    isFirst = false;
                }
            }
            if (facilities != null && facilities.size() > 0) {
                for (Integer num : facilities) {
                    if (!isFirst) {
                        body.append(",");
                    }
                    body.append(" ('F', ");
                    body.append(num.intValue());
                    body.append(" ) ");
                    isFirst = false;
                }
            }
            body.append(" ) ");
        }
        if (keyword != null && keyword.length() > 0) {
            hasKeyword = true;
            body.append(" AND (");
            body.append(
                    " t4.name LIKE #bind($keyword) OR t4.note LIKE #bind($keyword) OR t4.place LIKE #bind($keyword) ");
            body.append(" ) ");

        }
        body.append(
                " AND ( t4.public_flag = 'O' OR  ( t3.type = 'U' AND t3.user_id = #bind($user_id) ) OR  (t4.owner_id = #bind($user_id)) ) ");
        body.append(" ) ");
    } else {
        body.append(" FROM eip_t_schedule_map t3 ");
        if (isMySQL) {
            body.append(" FORCE INDEX (eip_t_schedule_map_schedule_id_index) ");
        }
        body.append(" , eip_t_schedule t4 ");
        body.append(" WHERE ");
        body.append(" t3.schedule_id = t4.schedule_id AND (t3.status <> 'R') ");
        if ((users != null && users.size() > 0) || (facilities != null && facilities.size() > 0)) {
            body.append(" AND (t3.type, t3.user_id) IN ( ");
            boolean isFirst = true;
            if (users != null && users.size() > 0) {
                for (Integer num : users) {
                    if (!isFirst) {
                        body.append(",");
                    }
                    body.append(" ('U', ");
                    body.append(num.intValue());
                    body.append(" ) ");
                    isFirst = false;
                }
            }
            if (facilities != null && facilities.size() > 0) {
                for (Integer num : facilities) {
                    if (!isFirst) {
                        body.append(",");
                    }
                    body.append(" ('F', ");
                    body.append(num.intValue());
                    body.append(" ) ");
                    isFirst = false;
                }
            }
            body.append(" ) ");
        }
        if (viewStart != null && viewEnd != null) {
            body.append(" AND ( ");
            body.append(" ( ");
            body.append(" t4.start_date <= '");
            body.append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(viewEnd));
            body.append("' ");
            body.append(" AND t4.end_date >= '");
            body.append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(viewStart));
            body.append("' ");
            body.append(" ) ");
            body.append(" OR  t4.repeat_pattern NOT IN ('N', 'S') ");
            body.append(" ) ");
        }
    }

    StringBuilder last = new StringBuilder();

    last.append(" ORDER BY t4.start_date DESC, t4.end_date DESC, t4.update_date DESC ");
    if (!isSearch) {
        last.append(" , t3.type DESC, t3.user_id ");
    }

    SQLTemplate<VEipTScheduleList> countQuery = Database
            .sql(VEipTScheduleList.class, count.toString() + body.toString())
            .param("user_id", Integer.valueOf(userId));
    if (hasKeyword) {
        countQuery.param("keyword", "%" + keyword + "%");
    }

    int countValue = 0;
    if (page > 0 && limit > 0) {
        List<DataRow> fetchCount = countQuery.fetchListAsDataRow();

        for (DataRow row : fetchCount) {
            countValue = ((Long) row.get("c")).intValue();
        }

        int offset = 0;
        if (limit > 0) {
            int num = ((int) (Math.ceil(countValue / (double) limit)));
            if ((num > 0) && (num < page)) {
                page = num;
            }
            offset = limit * (page - 1);
        } else {
            page = 1;
        }

        last.append(" LIMIT ");
        last.append(limit);
        last.append(" OFFSET ");
        last.append(offset);
    }

    SQLTemplate<VEipTScheduleList> query = Database
            .sql(VEipTScheduleList.class, select.toString() + body.toString() + last.toString())
            .param("user_id", Integer.valueOf(userId));
    if (hasKeyword) {
        query.param("keyword", "%" + keyword + "%");
    }

    List<DataRow> fetchList = query.fetchListAsDataRow();

    List<VEipTScheduleList> list = new ArrayList<VEipTScheduleList>();
    for (DataRow row : fetchList) {
        Long is_member = (Long) row.get("is_member");
        Long u_count = (Long) row.get("u_count");
        Long f_count = (Long) row.get("f_count");
        VEipTScheduleList object = Database.objectFromRowData(row, VEipTScheduleList.class);
        object.setMember(is_member.intValue() > 0);
        object.setUserCount(u_count.intValue());
        object.setFacilityCount(f_count.intValue());
        list.add(object);

    }

    if (page > 0 && limit > 0) {
        return new ResultList<VEipTScheduleList>(list, page, limit, countValue);
    } else {
        return new ResultList<VEipTScheduleList>(list, -1, -1, list.size());
    }

}

From source file:com.genscript.gsscm.product.service.ProductService.java

private Map<Integer, String> delPdtCategoryResult(Integer pdtCategoryId) {
    Map<Integer, String> retMap = null;
    // category??category.
    Long subCount = this.productCategoryDao.getSubPdtCategoryCount(pdtCategoryId);
    if (subCount.intValue() > 0) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASSUB);
        return retMap;
    }/*from   w  w  w .j  a  va 2s.c om*/
    // category?product?.
    Long productCount = this.productPriceDao.getCountByCategoryId(pdtCategoryId);
    if (productCount.intValue() > 0) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASPDTS);
        return retMap;
    }
    // Category??Approved
    if (checkPropertyApproved(pdtCategoryId, "name", RequestApproveType.ProductCategory.name())) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASAPPREQ);
        return retMap;
    }
    if (checkPropertyApproved(pdtCategoryId, "status", RequestApproveType.ProductCategory.name())) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASAPPREQ);
        return retMap;
    }
    return null;
}

From source file:com.genscript.gsscm.product.service.ProductService.java

private Map<Integer, String> delServCategoryResult(Integer pdtCategoryId) {
    Map<Integer, String> retMap = null;
    // category??category.
    Long subCount = this.serviceCategoryDao.getSubServCategoryCount(pdtCategoryId);

    if (subCount.intValue() > 0) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASSUB);
        return retMap;
    }// ww w .jav a  2  s.  co  m
    // category?product?.
    Long productCount = this.servicePriceDao.getCountByCategoryId(pdtCategoryId);
    if (productCount.intValue() > 0) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASPDTS);
        return retMap;
    }
    // Category??Approved
    if (checkPropertyApproved(pdtCategoryId, "name", RequestApproveType.ServiceCategory.name())) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASAPPREQ);
        return retMap;
    }
    if (checkPropertyApproved(pdtCategoryId, "status", RequestApproveType.ServiceCategory.name())) {
        retMap = new HashMap<Integer, String>();
        retMap.put(pdtCategoryId, BussinessException.DEL_PDTCATE_ERROR_HASAPPREQ);
        return retMap;
    }
    return null;
}

From source file:com.genscript.gsscm.product.service.ProductService.java

/**
 * Catalog?./* www .  ja v a2  s.  c  o m*/
 * 
 * @param id
 *            catalog.
 * @return null?, ?id??.
 */
private Map<Integer, String> delCatalogResult(Integer id) {
    Map<Integer, String> retMap = null;
    Catalog catalog = this.catalogDao.getById(id);
    if (catalog == null) {
        return null;
    }
    Long pdtCategoryCount = this.productCategoryDao.getCountByCatalogId(catalog.getCatalogId());
    if (pdtCategoryCount.intValue() > 0) {
        retMap = new HashMap<Integer, String>();
        retMap.put(id, BussinessException.DEL_CATALOG_ERROR_HASPDTCATE);
        return retMap;
    }
    boolean bApprove = checkPropertyApproved(id, "catalogName", RequestApproveType.Catalog.name())
            || checkPropertyApproved(id, "status", RequestApproveType.Catalog.name());
    if (bApprove) {
        retMap = new HashMap<Integer, String>();
        retMap.put(id, BussinessException.DEL_CATALOG_ERROR_HASAPPREQ);
        return retMap;
    }
    return null;
}

From source file:it.geosolutions.geofence.gui.server.service.impl.RulesManagerServiceImpl.java

public PagingLoadResult<Rule> getRules(int offset, int limit, boolean full) throws ApplicationException {
    int start = offset;

    List<Rule> ruleListDTO = new ArrayList<Rule>();

    long rulesCount = geofenceRemoteService.getRuleAdminService().getCountAll();

    Long t = new Long(rulesCount);

    int page = (start == 0) ? start : (start / limit);

    RuleFilter any = new RuleFilter(SpecialFilterType.ANY);
    List<ShortRule> rulesList = geofenceRemoteService.getRuleAdminService().getList(any, page, limit);

    if (rulesList == null) {
        if (logger.isErrorEnabled()) {
            logger.error("No rule found on server");
        }/*from   w  w w. ja  v a  2  s  . c o m*/
        throw new ApplicationException("No rule found on server");
    }

    Iterator<ShortRule> it = rulesList.iterator();

    while (it.hasNext()) {
        ShortRule shortRule = it.next();

        it.geosolutions.geofence.core.model.Rule fullRule;
        try {
            fullRule = geofenceRemoteService.getRuleAdminService().get(shortRule.getId());
        } catch (NotFoundServiceEx e) {
            if (logger.isErrorEnabled()) {
                logger.error("Details for rule " + shortRule.getPriority() + " not found on Server!");
            }
            throw new ApplicationException(
                    "Details for profile " + shortRule.getPriority() + " not found on Server!");
        }

        Rule ruleDTO = new Rule();

        ruleDTO.setId(shortRule.getId());
        ruleDTO.setPriority(fullRule.getPriority());

        if (fullRule.getGsuser() == null) {
            GSUser all = new GSUser();
            all.setId(-1);
            all.setName("*");
            ruleDTO.setUser(all);
        } else {
            it.geosolutions.geofence.core.model.GSUser remote_user = fullRule.getGsuser();
            GSUser local_user = new GSUser();
            local_user.setId(remote_user.getId());
            local_user.setName(remote_user.getName());
            ruleDTO.setUser(local_user);
        }

        if (fullRule.getUserGroup() == null) {
            UserGroup all = new UserGroup();
            all.setId(-1);
            all.setName("*");
            ruleDTO.setProfile(all);
        } else {
            it.geosolutions.geofence.core.model.UserGroup remote_profile = fullRule.getUserGroup();
            UserGroup local_profile = new UserGroup();
            local_profile.setId(remote_profile.getId());
            local_profile.setName(remote_profile.getName());
            ruleDTO.setProfile(local_profile);
        }

        if (fullRule.getInstance() == null) {
            GSInstance all = new GSInstance();
            all.setId(-1);
            all.setName("*");
            all.setBaseURL("*");
        } else {
            it.geosolutions.geofence.core.model.GSInstance remote_instance = fullRule.getInstance();
            GSInstance local_instance = new GSInstance();
            local_instance.setId(remote_instance.getId());
            local_instance.setName(remote_instance.getName());
            local_instance.setBaseURL(remote_instance.getBaseURL());
            local_instance.setUsername(remote_instance.getUsername());
            local_instance.setPassword(remote_instance.getPassword());
            ruleDTO.setInstance(local_instance);
        }

        ruleDTO.setSourceIPRange(
                fullRule.getAddressRange() != null ? fullRule.getAddressRange().getCidrSignature() : "*");

        ruleDTO.setService((fullRule.getService() != null) ? fullRule.getService() : "*");

        ruleDTO.setRequest((fullRule.getRequest() != null) ? fullRule.getRequest() : "*");

        ruleDTO.setWorkspace((fullRule.getWorkspace() != null) ? fullRule.getWorkspace() : "*");

        ruleDTO.setLayer((fullRule.getLayer() != null) ? fullRule.getLayer() : "*");

        ruleDTO.setGrant((fullRule.getAccess() != null) ? fullRule.getAccess().toString() : "ALLOW");

        ruleListDTO.add(ruleDTO);
    }

    return new RpcPageLoadResult<Rule>(ruleListDTO, offset, t.intValue());
}