Example usage for java.lang Long equals

List of usage examples for java.lang Long equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:nl.strohalm.cyclos.utils.CustomFieldHelper.java

/**
 * Finds a possible value reference on the collection
 *//*from  w  w  w  . j ava 2s .c o  m*/
public CustomFieldPossibleValue findPossibleValueById(final Long id,
        final Collection<CustomFieldPossibleValue> possibleValues) {
    if (EntityHelper.isValidId(id) && CollectionUtils.isNotEmpty(possibleValues)) {
        for (final CustomFieldPossibleValue possibleValue : possibleValues) {
            if (id.equals(possibleValue.getId())) {
                return possibleValue;
            }
        }
    }
    return null;
}

From source file:com.square.client.gwt.server.service.PersonnePhysiqueServiceGwtImpl.java

/**
 * Recherche l'adresse principale en cours parmi une liste d'adresses.
 * @param listeAdresses la liste d'adresses
 * @return l'adresse, null si pas trouve
 *//*from   w  ww .jav  a2 s . c  o m*/
private AdresseDto rechercherAdressePrincipaleEnCours(List<AdresseDto> listeAdresses) {
    final Long idNatureAdressePrincipale = squareMappingService.getIdNatureAdressePrincipale();
    final Calendar aujourdhui = Calendar.getInstance();
    // Parcours de la liste d'adresses
    if (listeAdresses != null) {
        for (AdresseDto adresse : listeAdresses) {
            // Si c'est une adresse principale
            if (adresse.getNature() != null
                    && idNatureAdressePrincipale.equals(adresse.getNature().getIdentifiant())) {
                // Test si l'adresse est active
                if (adresse.getDateDebut().before(aujourdhui)
                        && (adresse.getDateFin() == null || adresse.getDateFin().after(aujourdhui))) {
                    return adresse;
                }
            }
        }
    }
    return null;
}

From source file:br.gov.jfrj.siga.vraptor.GrupoController.java

/**
 * Grava o grupo e as configuraes/* ww  w. j  a v  a2  s .c o  m*/
 * @param idConfiguracao TODO
 * 
 * @throws AplicacaoException
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws InvocationTargetException
 */
public Long aGravar(Long idCpGrupo, String siglaGrupo, String dscGrupo, CpGrupoDeEmailSelecao grupoPaiSel,
        Integer codigoTipoConfiguracaoNova, String conteudoConfiguracaoNova, List<String> idConfiguracao,
        List<String> codigoTipoConfiguracao, List<String> conteudoConfiguracao) throws Exception {

    if (siglaGrupo == null) {
        throw new AplicacaoException("A sigla do grupo deve ser definida!");
    }

    idConfiguracao = Optional.fromNullable(idConfiguracao).or(new ArrayList<String>());

    codigoTipoConfiguracao = Optional.fromNullable(codigoTipoConfiguracao).or(new ArrayList<String>());

    conteudoConfiguracao = Optional.fromNullable(conteudoConfiguracao).or(new ArrayList<String>());

    try {
        CpGrupo grp = null;
        CpGrupo grpNovo = null;
        Date dt = dao().consultarDataEHoraDoServidor();
        CpTipoGrupo tpGrp = obterCpTipoGrupoPorId(getIdTipoGrupo());
        if (tpGrp == null) {
            throw new AplicacaoException("Tipo de grupo nulo para Id do grupo: " + idCpGrupo);
        }

        // Substituir isso por uma fbrica
        //
        if (tpGrp.getIdTpGrupo() == CpTipoGrupo.TIPO_GRUPO_GRUPO_DE_DISTRIBUICAO)
            grpNovo = new CpGrupoDeEmail();
        if (tpGrp.getIdTpGrupo() == CpTipoGrupo.TIPO_GRUPO_PERFIL_DE_ACESSO)
            grpNovo = new CpPerfil();
        if (tpGrp.getIdTpGrupo() == CpTipoGrupo.TIPO_GRUPO_PERFIL_JEE)
            grpNovo = new CpPerfilJEE();

        if (idCpGrupo == null) {
            grpNovo.setCpTipoGrupo(tpGrp);
            grpNovo.setOrgaoUsuario(getLotaTitular().getOrgaoUsuario());
        } else {
            grp = (CpGrupo) Objeto.getImplementation(daoGrupo(idCpGrupo));
            PropertyUtils.copyProperties(grpNovo, grp);
            grpNovo.setIdGrupo(null);
        }
        grpNovo.setCpGrupoPai(grupoPaiSel != null ? grupoPaiSel.getObjeto() : null);
        grpNovo.setDscGrupo(dscGrupo);
        grpNovo.setSiglaGrupo(siglaGrupo);

        dao().iniciarTransacao();
        grp = (CpGrupo) dao().gravarComHistorico(grpNovo, grp, dt, getIdentidadeCadastrante());
        idCpGrupo = grp.getIdGrupo();

        // Fabrica
        ConfiguracaoGrupoFabrica fabrica = new ConfiguracaoGrupoFabrica();
        // grava uma nova configurao

        TipoConfiguracaoGrupoEnum tpCfgGrpEnum = TipoConfiguracaoGrupoEnum.obterPara(tpGrp,
                codigoTipoConfiguracaoNova);
        if (tpCfgGrpEnum != null) {
            ConfiguracaoGrupo cfgGrp = fabrica.getInstance(tpCfgGrpEnum);
            if (isConfiguracaoAvancada(cfgGrp) && !podeEditarConfiguracoesAvancadas()) {
                throw new AplicacaoException("Voc no tem permisso para configurar "
                        + tpCfgGrpEnum.getDescricao()
                        + ". Por favor, entre em contato com o suporte tcnico para realizar tal configurao.");
            }

            if (conteudoConfiguracaoNova != null) {
                cfgGrp.setConteudoConfiguracao(conteudoConfiguracaoNova);
            }

            if (conteudoConfiguracaoNova == null || cfgGrp.getConteudoConfiguracao() == null
                    || cfgGrp.getConteudoConfiguracao().equals("")) {
                throw new AplicacaoException("Erro ao gravar nova configurao para o grupo: contedo do(a) "
                        + tpCfgGrpEnum.getDescricao() + " inexistente! ");
            }
            CpConfiguracao cfg = new CpConfiguracao();
            cfg.setCpTipoConfiguracao(tipoConfiguracao);
            cfg.setHisDtIni(dt);
            cfgGrp.setCpConfiguracao(cfg);
            cfgGrp.setCpGrupo(grp);
            cfgGrp.atualizarCpConfiguracao();
            dao().gravarComHistorico(cfg, getIdentidadeCadastrante());
        }

        // processa as configuraes existentes
        configuracoesGrupo = Cp.getInstance().getConf().obterCfgGrupo(grp);
        for (int i = 0; i < idConfiguracao.size(); i++) {
            Long idCfg = Long.parseLong(idConfiguracao.get(i));
            for (ConfiguracaoGrupo cfgGrpGravada : configuracoesGrupo) {
                Long idCfgGravada = cfgGrpGravada.getCpConfiguracao().getIdConfiguracao();
                if (idCfgGravada.equals(idCfg)) {
                    Integer tpCfg = Integer.parseInt(codigoTipoConfiguracao.get(i));
                    // Remoo de uma configurao gravada antes
                    if (tpCfg.equals(-1)) {
                        // excluso remove apenas logicamente, deixa o
                        // registro antigo como log
                        if (isConfiguracaoAvancada(cfgGrpGravada) && !podeEditarConfiguracoesAvancadas()) {
                            throw new AplicacaoException("Voc no tem permisso para remover "
                                    + cfgGrpGravada.getTipo().getDescricao()
                                    + ". Por favor, entre em contato com o suporte tcnico para realizar tal configurao.");
                        }

                        cfgGrpGravada.getCpConfiguracao().setHisDtFim(dt);
                        dao().gravarComHistorico(cfgGrpGravada.getCpConfiguracao(), getIdentidadeCadastrante());
                    } else {
                        String cfgConteudo = conteudoConfiguracao.get(i);
                        // Nato: o ideal seria se pudssemos utilizar o
                        // mtodo "semelhante" para comparar configuraes.
                        // No entanto, como as configuraes anteriores so
                        // lidas do "cache-da-aplicao", e no do
                        // Hibernate, fica impossvel fazer a comparao
                        // automaticamente. Por isso,  necessrio esse "if"
                        // que s grava alteraes se no for do mesmo tipo
                        // ou no tiver mesmo contedo que a gravada
                        if (!tpCfg.equals(cfgGrpGravada.getTipo().getCodigo())
                                || !cfgConteudo.equals(cfgGrpGravada.getConteudoConfiguracao())) {
                            TipoConfiguracaoGrupoEnum tpCfgGrpNova = TipoConfiguracaoGrupoEnum.obterPara(tpGrp,
                                    tpCfg);
                            ConfiguracaoGrupo cfgGrpNova = fabrica.getInstance(tpCfgGrpNova);
                            if (isConfiguracaoAvancada(cfgGrpNova) && !podeEditarConfiguracoesAvancadas()) {
                                throw new AplicacaoException("Voc no tem permisso para configurar "
                                        + tpCfgGrpNova.getDescricao()
                                        + ". Por favor, entre em contato com o suporte tcnico para realizar tal configurao.");
                            }
                            if (cfgConteudo == null || cfgConteudo.equals("")) {
                                throw new AplicacaoException(
                                        "Erro ao gravar alterao da configurao para o grupo: contedo do(a)"
                                                + tpCfgGrpEnum.getDescricao() + " inexistente!");
                            }
                            cfgGrpNova.setConteudoConfiguracao(cfgConteudo);
                            CpConfiguracao cfgNova = new CpConfiguracao();
                            cfgNova.setCpTipoConfiguracao(tipoConfiguracao);
                            cfgGrpNova.setCpConfiguracao(cfgNova);
                            cfgGrpNova.setCpGrupo(grp);
                            cfgGrpNova.atualizarCpConfiguracao();
                            dao().gravarComHistorico(cfgNova, cfgGrpGravada.getCpConfiguracao(), dt,
                                    getIdentidadeCadastrante());
                        }
                    }
                }
            }
        }

        dao().commitTransacao();
        Cp.getInstance().getConf().limparCache(
                dao().consultar(CpTipoConfiguracao.TIPO_CONFIG_PERTENCER, CpTipoConfiguracao.class, false));
        return idCpGrupo;
    } catch (Exception e) {
        throw new AplicacaoException("Id do grupo: " + idCpGrupo + " erro ao gravar grupo e configuraes.", 0,
                e);
    }
}

From source file:ome.security.basic.BasicACLVoter.java

private boolean allowUpdateOrDelete(IObject iObject, Details trustedDetails, boolean update) {
    Assert.notNull(iObject);// w  w  w .java 2s .  c om

    BasicEventContext c = currentUser.current();
    Long uid = c.getCurrentUserId();

    boolean sysType = sysTypes.isSystemType(iObject.getClass())
            || sysTypes.isInSystemGroup(iObject.getDetails());
    boolean sysTypeOrUsrGroup = sysType || sysTypes.isInUserGroup(iObject.getDetails());

    // needs no details info
    if (tokenHolder.hasPrivilegedToken(iObject)) {
        return true; // ticket:1794, allow move to "user
    } else if (update && !sysTypeOrUsrGroup && currentUser.isGraphCritical()) { //ticket:1769
        return objectBelongsToUser(iObject, uid);
    } else if (c.isCurrentUserAdmin()) {
        return true;
    } else if (sysType) {
        return false;
    }

    // previously we were taking the details directly from iObject
    // iObject, however, is in a critical state. Values such as
    // Permissions, owner, and group may have been changed.
    Details d = trustedDetails;

    // this can now only happen if a table doesn't have permissions
    // and there aren't any of those. so let it be updated.
    if (d == null) {
        return true;
    }

    // the owner and group information might be null if the type
    // is intended to be a system-type but isn't marked as one
    // via SecuritySystem.isSystemType(). A NPE here might imply
    // that that information is out of sync.
    Long o = d.getOwner() == null ? null : d.getOwner().getId();
    Long g = d.getGroup() == null ? null : d.getGroup().getId();

    // needs no permissions info
    if (g != null && c.getLeaderOfGroupsList().contains(g)) {
        return true;
    }

    Permissions p = d.getPermissions();

    // this should never occur.
    if (p == null) {
        throw new InternalException("Permissions null! Security system "
                + "failure -- refusing to continue. The Permissions should " + "be set to a default value.");
    }

    // standard
    if (p.isGranted(WORLD, WRITE)) {
        return true;
    }
    if (p.isGranted(USER, WRITE) && o != null && o.equals(c.getOwner().getId())) {
        return true;
    }
    /* ticket:1992 - removing concept of GROUP-WRITE
    if (p.isGranted(GROUP, WRITE) && g != null
        && c.getMemberOfGroupsList().contains(g)) {
    return true;
    }
    */

    return false;
}

From source file:com.selfsoft.business.service.impl.StatisticsStockInOutServiceImpl.java

/**
 *  ?//  w  w w  .  j av  a2s.c  om
 * @Date      2010-7-13
 * @Function  
 * @param tmStoreHouseReceiverStatVo
 * @return
 */
public List<TmStoreHouseReceiverStatVo> getStoreHouseReceiverStat(
        TmStoreHouseReceiverStatVo tmStoreHouseReceiverStatVo) {

    List<TmStoreHouseReceiverStatVo> results = new ArrayList<TmStoreHouseReceiverStatVo>();

    List<Object[]> list = tbPartInfoDao.getStoreHouseReceiverStat(tmStoreHouseReceiverStatVo);

    for (Object[] obj : list) {
        TmStoreHouseReceiverStatVo vo = new TmStoreHouseReceiverStatVo();
        vo.setStoreHouseName(obj[0] != null ? obj[0].toString() : null);
        vo.setInOutType(obj[2] != null ? Long.valueOf(obj[2].toString()) : null);
        vo.setInOutTypeName(
                obj[2] != null ? StockTypeElements.getElementMap().get(new Long(obj[2].toString())) : null);
        Long type = Long.valueOf(obj[3].toString());
        if (type.equals(0L)) {
            //
            vo.setStockOutCostPrice(obj[4] != null ? Double.valueOf(obj[4].toString()) : 0D);
            vo.setSellCostPrice(obj[5] != null ? Double.valueOf(obj[5].toString()) : 0D);
        }
        if (type.equals(1L)) {
            //
            vo.setStockInCostPrice(obj[4] != null ? Double.valueOf(obj[4].toString()) : 0D);
        }

        results.add(vo);
    }

    return results;
}

From source file:com.vmware.appfactory.workpool.controller.WorkpoolApiController.java

/**
 * Method to return the total number of workpools for a given Linkedworkpool image.
 * The image is only applicable for LinkedWorkpools.
 *
 * Various values and the inference://from www.j  a v  a 2  s  .  com
 *  0 : workpool does not have an image.
 *  1 : This is the only workpool that is tied to this image.
 *  2+: There are other workpools that have the same image associated.
 *
 * @param workpoolId
 * @return Integer
 * @throws AfNotFoundException
 * @throws WpException
 */
@ResponseBody
@RequestMapping(value = "/workpools/imageLinkCount/{workpoolId}", method = RequestMethod.GET)
public Integer imageAssociatedToWorkpoolCount(@PathVariable Long workpoolId)
        throws AfNotFoundException, WpException {
    Workpool wp = _wpClient.getWorkpoolById(workpoolId);
    // If LinkedWorkpool, only then there are images.
    int count = 0;
    if (wp instanceof LinkedWorkpool) {
        Long imageId = ((LinkedWorkpool) wp).getVmImage().getId();
        List<Workpool> wpList = _wpClient.getAllWorkpools();

        // For each workpool, check if the image is used by other workpool
        for (Workpool w : wpList) {
            if (w instanceof LinkedWorkpool) {
                VmImage i = ((LinkedWorkpool) w).getVmImage();
                if (imageId.equals(i.getId())) {
                    count++;
                }
            }
        }
    }
    return Integer.valueOf(count);
}

From source file:jp.primecloud.auto.ui.WinServerAdd.java

private void showServices(Long platformNo, Long imageNo) {
    serviceTable.removeAllItems();//from   w  w w .j  a  va2s.  com
    if (platformNo == null || imageNo == null) {
        return;
    }

    // ???
    List<ComponentType> componentTypes = null;
    for (PlatformDto platform : platforms) {
        if (platformNo.equals(platform.getPlatform().getPlatformNo())) {
            List<ImageDto> images = platform.getImages();
            for (ImageDto image : images) {
                if (imageNo.equals(image.getImage().getImageNo())) {
                    this.selectImage = image;

                    componentTypes = image.getComponentTypes();
                    //?
                    String caption = image.getImage().getImageNameDisp();
                    caption = "" + caption + "?????";
                    serviceTable.setCaption(caption);

                    break;
                }
            }
            break;
        }
    }

    // ????
    if (componentTypes == null) {
        return;
    }

    // ?
    for (int i = 0; i < componentTypes.size(); i++) {
        ComponentType componentType = componentTypes.get(i);

        // ??
        String name = componentType.getComponentTypeNameDisp();
        Icons nameIcon = Icons.fromName(componentType.getComponentTypeName());

        Label slbl = new Label(
                "<img src=\"" + VaadinUtils.getIconPath(apl, nameIcon) + "\"><div>" + name + "</div>",
                Label.CONTENT_XHTML);
        slbl.setHeight("26px");

        // 
        String description = componentType.getLayerDisp();

        serviceTable.addItem(new Object[] { slbl, description }, componentType.getComponentTypeNo());
    }
}

From source file:com.splout.db.qnode.QNodeHandlerContext.java

/**
 * Rotates the versions (deletes versions that are old or useless). To be executed at startup and after a deployment.
 *///w w  w.  j a v  a 2  s .com
public List<com.splout.db.thrift.TablespaceVersion> synchronizeTablespaceVersions()
        throws InterruptedException {
    log.info("Starting to look for old tablespace versions to remove...");

    int maxVersionsPerTablespace = config.getInt(QNodeProperties.VERSIONS_PER_TABLESPACE);

    // Will contain the list of versions per each tablespace, sorted by creation date descendant
    TreeMultimap<String, Tablespace> tablespaces = TreeMultimap.create(Ordering.natural(),
            new Comparator<Tablespace>() {
                @Override
                public int compare(Tablespace tb1, Tablespace tb2) {
                    // reverse ordering. Older dates appears LAST. If same date, then version is compared.
                    int comp = -((Long) tb1.getCreationDate()).compareTo(tb2.getCreationDate());
                    if (comp == 0) {
                        return -((Long) tb1.getVersion()).compareTo(tb2.getVersion());
                    } else {
                        return comp;
                    }
                }
            });

    Map<TablespaceVersion, Tablespace> myTablespaces = getTablespaceVersionsMap();

    // We build a in memory version of tablespaces for analyzing it
    // and prune old ones.
    for (Entry<TablespaceVersion, Tablespace> entry : myTablespaces.entrySet()) {
        tablespaces.put(entry.getKey().getTablespace(), entry.getValue());
    }
    log.info("Analyzing " + tablespaces.keySet().size() + " tablespaces with a total of " + tablespaces.size()
            + " versions...");

    // We will remove only versions older than the one being served
    Map<String, Long> hzVersionsBeingServed = coordinationStructures.getCopyVersionsBeingServed();
    if (hzVersionsBeingServed == null) {
        log.info("... No versions yet being served.");
        return null; // nothing to do yet
    }
    log.info("Number of versions being served: " + hzVersionsBeingServed.size());

    List<com.splout.db.thrift.TablespaceVersion> tablespacesToRemove = new ArrayList<com.splout.db.thrift.TablespaceVersion>();

    for (Entry<String, Long> entry : hzVersionsBeingServed.entrySet()) {
        String tablespace = entry.getKey();
        Long versionBeingServed = entry.getValue();
        // Tablespaces are sorted by creation date desc.
        SortedSet<Tablespace> allVersions = tablespaces.get(tablespace);
        Iterator<Tablespace> it = allVersions.iterator();
        boolean foundVersionBeingServed = false;
        int countVersionsAfter = 0;
        while (it.hasNext()) {
            Tablespace tb = it.next();
            if (versionBeingServed.equals(tb.getVersion())) {
                foundVersionBeingServed = true;
            } else {
                if (foundVersionBeingServed) {
                    countVersionsAfter++;
                    if (countVersionsAfter >= maxVersionsPerTablespace) {
                        // This is the case where we remove the version
                        // 1 - This tablespace has a version being served
                        // 2 - This version is older than the current tablespace being served
                        // 3 - We are already keeping maxVersionsPerTablespace versions
                        tablespacesToRemove
                                .add(new com.splout.db.thrift.TablespaceVersion(tablespace, tb.getVersion()));
                        log.info("Tablespace [" + tablespace + "] Version [" + tb.getVersion() + "] "
                                + "created at [" + new Date(tb.getCreationDate())
                                + "] REMOVED. We already keep younger versions.");
                    } else {
                        log.info("Tablespace [" + tablespace + "] Version [" + tb.getVersion() + "] "
                                + "created at [" + new Date(tb.getCreationDate()) + "] KEPT.");
                    }
                } else {
                    log.info("Tablespace [" + tablespace + "] Version [" + tb.getVersion() + "] "
                            + "created at [" + new Date(tb.getCreationDate())
                            + "] either younger than served one or without version being served. Keeping.");
                }
            }
        }

        if (!foundVersionBeingServed) {
            log.info("Tablespace [" + tablespace
                    + "] without any version being served. Please, have a look, and remove them if not used");
        }

        if (tablespacesToRemove.size() > 0) {
            log.info("Sending [" + tablespacesToRemove + "] to all alive DNodes.");
            for (DNodeInfo dnode : coordinationStructures.getDNodes().values()) {
                DNodeService.Client client = null;
                boolean renew = false;
                try {
                    client = getDNodeClientFromPool(dnode.getAddress());
                    client.deleteOldVersions(tablespacesToRemove);
                } catch (TTransportException e) {
                    renew = true;
                    log.warn("Failed sending delete TablespaceVersions order to (" + dnode
                            + "). Not critical as they will be removed after other deployments.", e);
                } catch (Exception e) {
                    log.warn("Failed sending delete TablespaceVersions order to (" + dnode
                            + "). Not critical as they will be removed after other deployments.", e);
                } finally {
                    if (client != null) {
                        returnDNodeClientToPool(dnode.getAddress(), client, renew);
                    }
                }
            }
        }
        log.info("... done looking for old tablespace versions to remove...");
    }

    return tablespacesToRemove; // Return for unit test
}

From source file:au.org.theark.lims.model.dao.InventoryDao.java

public void updateInvSite(LimsVO modelObject) {

    InvSite invSite = modelObject.getInvSite();
    Session session = getSession();// w  ww  .j av a2s.  com
    session.update(invSite);
    session.flush();
    session.refresh(invSite);
    List<StudyInvSite> existingInvSites = invSite.getStudyInvSites();

    //for (StudyInvSite sis : modelObject.getInvSite().getStudyInvSites()) {
    //      session.delete(sis);
    //      session.flush();
    //}

    List<Long> selectedAndExistingStudies = new ArrayList<Long>();
    List<Study> selectedStudies = modelObject.getSelectedStudies();

    for (Study selectedStudy : selectedStudies) {
        boolean studyAlreadyLinked = false;
        log.info("selected =" + selectedStudy.getId());

        for (StudyInvSite sis : existingInvSites) {
            Study existingStudy = sis.getStudy();
            log.info("  existing=" + selectedStudy.getId());
            if (existingStudy.getId().equals(selectedStudy.getId())) {
                log.info("found a match for " + selectedStudy.getId());
                studyAlreadyLinked = true;
                selectedAndExistingStudies.add(selectedStudy.getId());
                break; // leave it along
            }
        }

        if (!studyAlreadyLinked) {
            log.info("about to create" + selectedStudy.getId());
            StudyInvSite studyInvSite = new StudyInvSite();
            studyInvSite.setStudy(selectedStudy);
            studyInvSite.setInvSite(invSite);
            session.save(studyInvSite);
        }

    }

    for (StudyInvSite sis : existingInvSites) {
        log.info("about to investigate for deletion existing study " + sis.getStudy().getId());
        boolean deletePreviouslyExistingSiteAsItWasNotSelected = true;
        for (Long selectedId : selectedAndExistingStudies) {
            log.info("compare it to selected " + selectedId);
            if (selectedId.equals(sis.getStudy().getId())) {
                log.info("recommending you don't delete");
                deletePreviouslyExistingSiteAsItWasNotSelected = false;
            } else {
                log.info("match not found.");
            }
        }
        if (deletePreviouslyExistingSiteAsItWasNotSelected) {
            log.info("deleting " + sis.getStudy().getId());
            session.delete(sis);
        }
    }
    session.flush();
    session.refresh(invSite);

    //List<StudyInvSite> existingInvSites = invSite.getStudyInvSites();

    //for (StudyInvSite sis : modelObject.getInvSite().getStudyInvSites()) {
    //   session.delete(sis);
    //   session.flush();
    //}

    /*
            
    List<Study> selectedAndExistingStudies = new ArrayList<Study>();
    List<Study> selectedStudies = modelObject.getSelectedStudies();
            
    for (Study selectedStudy : selectedStudies) {
       boolean studyAlreadyLinked = false;
       for(StudyInvSite sis: existingInvSites){
    Study existingStudy = sis.getStudy();
    if(existingStudy.equals(selectedStudy)){
       studyAlreadyLinked = true;
       selectedAndExistingStudies.add(selectedStudy);
       break; // leave it along
    }
       }
               
       if(!studyAlreadyLinked){
    StudyInvSite studyInvSite = new StudyInvSite();
    studyInvSite.setStudy(selectedStudy);
    studyInvSite.setInvSite(modelObject.getInvSite());
    session.save(studyInvSite);
       }
               
    }
            
    for(StudyInvSite sis: existingInvSites){
       if(!selectedAndExistingStudies.contains(sis.getStudy())){
    session.delete(sis);
       }
    }
    */
}

From source file:com.selfsoft.business.service.impl.StatisticsStockInOutServiceImpl.java

/**
 *  ?/*from  w ww  .ja v  a 2 s. c  o m*/
 * @Date      2010-7-13
 * @Function  
 * @param tmStoreHouseReceiverStatVo
 * @return
 */
public List<TmStoreHouseReceiverStatVo> getStoreHouseReceiverStatByMonth(String year, String mounth) {

    if (year == null || mounth == null)
        return null;

    List<TmStoreHouseReceiverStatVo> results = new ArrayList<TmStoreHouseReceiverStatVo>();

    List<Object[]> list = tbPartInfoDao.getStoreHouseReceiverStat(year, mounth);

    for (Object[] obj : list) {
        TmStoreHouseReceiverStatVo vo = new TmStoreHouseReceiverStatVo();
        vo.setStoreHouseName(obj[0] != null ? obj[0].toString() : null);
        vo.setInOutType(obj[2] != null ? Long.valueOf(obj[2].toString()) : null);
        vo.setInOutTypeName(
                obj[2] != null ? StockTypeElements.getElementMap().get(new Long(obj[2].toString())) : null);
        Long type = Long.valueOf(obj[3].toString());
        if (type.equals(0L)) {
            //
            vo.setStockOutCostPrice(obj[4] != null ? Double.valueOf(obj[4].toString()) : 0D);
            vo.setSellCostPrice(obj[5] != null ? Double.valueOf(obj[5].toString()) : 0D);
        }
        if (type.equals(1L)) {
            //
            vo.setStockInCostPrice(obj[4] != null ? Double.valueOf(obj[4].toString()) : 0D);
        }

        vo.setStoreHouseId(obj[1] != null ? new Long(obj[1].toString()) : null);

        Double inBeginCount = tbPartInfoDao.getInTmStoreHouseAsBegin(vo.getStoreHouseId(), year, mounth,
                vo.getInOutType());
        Double inFinalCount = tbPartInfoDao.getInTmStoreHouseAsFinal(vo.getStoreHouseId(), year, mounth,
                vo.getInOutType());

        Double outBeginCount = tbPartInfoDao.getOutTmStoreHouseAsBegin(vo.getStoreHouseId(), year, mounth,
                vo.getInOutType());
        Double outFinalCount = tbPartInfoDao.getOutTmStoreHouseAsFinal(vo.getStoreHouseId(), year, mounth,
                vo.getInOutType());

        //
        Double incount = (inBeginCount - outBeginCount);
        //?
        Double outcount = (inFinalCount - outFinalCount);

        vo.setQcPrice(CommonMethod.convertRadixPoint(incount, 2));
        vo.setQmPrice(CommonMethod.convertRadixPoint(outcount, 2));
        results.add(vo);
    }

    return results;
}