Example usage for org.hibernate Criteria createCriteria

List of usage examples for org.hibernate Criteria createCriteria

Introduction

In this page you can find the example usage for org.hibernate Criteria createCriteria.

Prototype

public Criteria createCriteria(String associationPath, String alias) throws HibernateException;

Source Link

Document

Create a new Criteria, "rooted" at the associated entity, assigning the given alias.

Usage

From source file:com.webbfontaine.valuewebb.action.pricedb.prd.PRDCriteriaContainer.java

License:Open Source License

@Override
public Criteria transformUserCriteria(Session session) throws Exception {

    Criteria criteria = session.createCriteria(Pd.class).add(Example.create(new Pd()).excludeZeroes());
    criteria.createCriteria("ttGen", "ttGen");
    criteria.createCriteria("ttInv", "ttInv");

    Junction junction = getMatchAll() ? Restrictions.conjunction() : Restrictions.disjunction();

    List<UserCriterion> selectedUserCriteria = getSelectedUserCriteria();
    for (UserCriterion userCriterion : selectedUserCriteria) {

        Criterion transformedCriterion;/* w  w  w. j ava  2 s . c om*/
        if ("ageOfPrice".equals(userCriterion.getFullKey())) {
            transformedCriterion = MPCriteriaContainer.transformAgeOfPriceToPriceDate(userCriterion,
                    getDefinedCriterion("ttInv.invDat"));
        } else {
            transformedCriterion = userCriterion.transform();
        }

        if (transformedCriterion != null) {
            criteria.add(junction.add(transformedCriterion));
        }
    }

    return criteria;
}

From source file:de.decidr.model.commands.tenant.GetWorkflowInstancesCommand.java

License:Apache License

@SuppressWarnings("unchecked")
@Override// w  ww  .  j  av a  2 s.  co  m
public void transactionAllowed(TransactionStartedEvent evt) throws TransactionException {

    String hql = "select t.id from Tenant t where t.id  = :tenantId";
    Boolean tenantExists = evt.getSession().createQuery(hql).setLong("tenantId", getTenantId())
            .uniqueResult() != null;

    if (!tenantExists) {
        throw new EntityNotFoundException(Tenant.class, getTenantId());
    }

    PaginatingCriteria c = new PaginatingCriteria(WorkflowInstance.class, evt.getSession());

    Criteria c2;

    // create criteria 2nd level and project to name
    c2 = c.createCriteria("deployedWorkflowModel", CriteriaSpecification.INNER_JOIN);

    // create criteria 3rd level and project to name
    c2.createCriteria("tenant", CriteriaSpecification.INNER_JOIN).add(Restrictions.idEq(getTenantId()));

    if (paginator != null) {
        paginator.apply(c);
    }

    c.setResultTransformer(CriteriaSpecification.ROOT_ENTITY);

    result = c.list();
}

From source file:de.decidr.model.commands.workflowmodel.WorkflowModelCommand.java

License:Apache License

/**
 * Fetches the current deployed version of the workflow model.
 * /* ww w . j a  va  2s  . co  m*/
 * @param session
 *            current Hibernate Session
 * @return the current deployed version of the workflow model or null if
 *         there is no current deplyoed version.
 */
public DeployedWorkflowModel fetchCurrentDeployedWorkflowModel(Session session) {
    Criteria crit = session.createCriteria(DeployedWorkflowModel.class, "dwm");

    crit.createCriteria("originalWorkflowModel", "owm")
            .add(Restrictions.eqProperty("owm.version", "dwm.version"));

    crit.add(Restrictions.eq("originalWorkflowModel.id", getWorkflowModelId()));

    return (DeployedWorkflowModel) crit.setResultTransformer(CriteriaSpecification.ROOT_ENTITY).uniqueResult();
}

From source file:de.powerstaff.business.dao.hibernate.StatistikDAOHibernateImpl.java

License:Open Source License

@Override
public List<KontakthistorieEntry> kontakthistorie(final Date aDatumVon, final Date aDatumBis,
        final User aBenutzer) {
    return (List<KontakthistorieEntry>) getHibernateTemplate().execute(new HibernateCallback() {

        @Override/* ww  w  .  j  a  va 2 s.  c o  m*/
        public Object doInHibernate(Session aSession) throws SQLException {
            List<KontakthistorieEntry> theResult = new ArrayList<KontakthistorieEntry>();

            Conjunction theRestrictions = Restrictions.conjunction();
            if (aDatumVon != null) {
                theRestrictions.add(Restrictions.ge("h.creationDate", aDatumVon));
            }
            if (aDatumBis != null) {
                theRestrictions.add(Restrictions.le("h.creationDate", aDatumBis));
            }
            if (aBenutzer != null) {
                theRestrictions.add(Restrictions.eq("h.creationUserID", aBenutzer.getUsername()));
            }

            // Freiberufler
            Criteria theCriteria = aSession.createCriteria(Freelancer.class, "p");
            theCriteria.createCriteria("history", "h");
            theCriteria.add(theRestrictions);

            ProjectionList theProjections = Projections.projectionList();
            theProjections.add(Projections.property("p.name1"));
            theProjections.add(Projections.property("p.name2"));
            theProjections.add(Projections.property("p.code"));
            theProjections.add(Projections.property("h.creationDate"));
            theProjections.add(Projections.property("h.creationUserID"));
            theProjections.add(Projections.property("h.type"));
            theProjections.add(Projections.property("h.description"));

            theCriteria.setProjection(theProjections);
            for (Object theResultObject : theCriteria.list()) {
                Object[] theResultArray = (Object[]) theResultObject;

                KontakthistorieEntry theEntry = new KontakthistorieEntry();
                theEntry.setName1((String) theResultArray[0]);
                theEntry.setName2((String) theResultArray[1]);
                theEntry.setCode((String) theResultArray[2]);
                Timestamp theTimestamp = (Timestamp) theResultArray[3];
                theEntry.setDatum(new Date(theTimestamp.getTime()));
                theEntry.setUserid((String) theResultArray[4]);
                theEntry.setType((HistoryType) theResultArray[5]);
                theEntry.setDescription((String) theResultArray[6]);

                theResult.add(theEntry);
            }

            // Partner
            theCriteria = aSession.createCriteria(Partner.class, "p");
            theCriteria.createCriteria("history", "h");
            theCriteria.add(theRestrictions);

            theProjections = Projections.projectionList();
            theProjections.add(Projections.property("p.name1"));
            theProjections.add(Projections.property("p.name2"));
            theProjections.add(Projections.property("h.creationDate"));
            theProjections.add(Projections.property("h.creationUserID"));
            theProjections.add(Projections.property("h.type"));
            theProjections.add(Projections.property("h.description"));

            theCriteria.setProjection(theProjections);
            for (Object theResultObject : theCriteria.list()) {
                Object[] theResultArray = (Object[]) theResultObject;

                KontakthistorieEntry theEntry = new KontakthistorieEntry();
                theEntry.setName1((String) theResultArray[0]);
                theEntry.setName2((String) theResultArray[1]);
                Timestamp theTimestamp = (Timestamp) theResultArray[2];
                theEntry.setDatum(new Date(theTimestamp.getTime()));
                theEntry.setUserid((String) theResultArray[3]);
                theEntry.setType((HistoryType) theResultArray[4]);
                theEntry.setDescription((String) theResultArray[5]);

                theResult.add(theEntry);
            }

            // Kunden
            theCriteria = aSession.createCriteria(Customer.class, "p");
            theCriteria.createCriteria("history", "h");
            theCriteria.add(theRestrictions);

            theProjections = Projections.projectionList();
            theProjections.add(Projections.property("p.name1"));
            theProjections.add(Projections.property("p.name2"));
            theProjections.add(Projections.property("h.creationDate"));
            theProjections.add(Projections.property("h.creationUserID"));
            theProjections.add(Projections.property("h.type"));
            theProjections.add(Projections.property("h.description"));

            theCriteria.setProjection(theProjections);
            for (Object theResultObject : theCriteria.list()) {
                Object[] theResultArray = (Object[]) theResultObject;

                KontakthistorieEntry theEntry = new KontakthistorieEntry();
                theEntry.setName1((String) theResultArray[0]);
                theEntry.setName2((String) theResultArray[1]);
                Timestamp theTimestamp = (Timestamp) theResultArray[2];
                theEntry.setDatum(new Date(theTimestamp.getTime()));
                theEntry.setUserid((String) theResultArray[3]);
                theEntry.setType((HistoryType) theResultArray[4]);
                theEntry.setDescription((String) theResultArray[5]);

                theResult.add(theEntry);
            }

            Collections.sort(theResult, new ReverseComparator(new BeanComparator("datum")));

            return theResult;
        }
    });
}

From source file:de.sub.goobi.forms.AdministrationForm.java

License:Open Source License

/**
 * Correct PPNs.//from  w ww.j a  v a  2  s.  co  m
 */
@SuppressWarnings("unchecked")
public void PPNsKorrigieren() throws DAOException {
    Session session = Helper.getHibernateSession();
    Criteria crit = session.createCriteria(Process.class);
    crit.add(Restrictions.eq("template", Boolean.FALSE));
    crit.createCriteria("project", "proj");
    crit.add(Restrictions.like("proj.titel", "DigiZeitschriften"));

    List<Process> auftraege = crit.list();

    /* alle Prozesse durchlaufen */
    for (Process p : auftraege) {
        if (serviceManager.getProcessService().getBlockedUsers(p) != null) {
            Helper.setFehlerMeldung("metadata locked: ", p.getTitle());
        } else {
            String myBandnr = p.getTitle();
            StringTokenizer tokenizer = new StringTokenizer(p.getTitle(), "_");
            while (tokenizer.hasMoreTokens()) {
                myBandnr = "_" + tokenizer.nextToken();
            }
            Prefs myPrefs = serviceManager.getRulesetService().getPreferences(p.getRuleset());
            try {
                Fileformat gdzfile = serviceManager.getProcessService().readMetadataFile(p);
                DocStruct dsTop = gdzfile.getDigitalDocument().getLogicalDocStruct();
                DocStruct dsFirst = null;
                if (dsTop.getAllChildren() != null && dsTop.getAllChildren().size() > 0) {
                    dsFirst = dsTop.getAllChildren().get(0);
                }

                MetadataType mdtPpnDigital = UghHelper.getMetadataType(myPrefs, "CatalogIDDigital");
                MetadataType mdtPpnAnalog = UghHelper.getMetadataType(myPrefs, "CatalogIDSource");
                List<? extends Metadata> alleMetadaten;

                /* digitale PPN korrigieren */
                if (dsFirst != null) {
                    alleMetadaten = dsFirst.getAllMetadataByType(mdtPpnDigital);
                    if (alleMetadaten != null && alleMetadaten.size() > 0) {
                        Metadata md = alleMetadaten.get(0);
                        myLogger.debug(md.getValue());
                        if (!md.getValue().endsWith(myBandnr)) {
                            md.setValue(md.getValue() + myBandnr);
                            Helper.setMeldung(null, "PPN digital adjusted: ", p.getTitle());
                        }
                    }

                    /* analoge PPN korrigieren */
                    alleMetadaten = dsFirst.getAllMetadataByType(mdtPpnAnalog);
                    if (alleMetadaten != null && alleMetadaten.size() > 0) {
                        Metadata md1 = alleMetadaten.get(0);
                        myLogger.debug(md1.getValue());
                        if (!md1.getValue().endsWith(myBandnr)) {
                            md1.setValue(md1.getValue() + myBandnr);
                            Helper.setMeldung(null, "PPN analog adjusted: ", p.getTitle());
                        }
                    }
                }

                /* Collections korrigieren */
                List<String> myKollektionenTitel = new ArrayList<String>();
                MetadataType coltype = UghHelper.getMetadataType(myPrefs, "singleDigCollection");
                ArrayList<Metadata> myCollections;
                if (dsTop.getAllMetadataByType(coltype) != null
                        && dsTop.getAllMetadataByType(coltype).size() != 0) {
                    myCollections = new ArrayList<Metadata>(dsTop.getAllMetadataByType(coltype));
                    if (myCollections.size() > 0) {
                        for (Metadata md : myCollections) {

                            if (myKollektionenTitel.contains(md.getValue())) {
                                dsTop.removeMetadata(md);
                            } else {
                                myKollektionenTitel.add(md.getValue());
                            }
                        }
                    }
                }
                if (dsFirst != null && dsFirst.getAllMetadataByType(coltype) != null) {
                    myKollektionenTitel = new ArrayList<String>();
                    myCollections = new ArrayList<Metadata>(dsFirst.getAllMetadataByType(coltype));
                    if (myCollections.size() > 0) {
                        for (Metadata md : myCollections) {
                            // Metadata md = (Metadata) it.next();
                            if (myKollektionenTitel.contains(md.getValue())) {
                                dsFirst.removeMetadata(md);
                            } else {
                                myKollektionenTitel.add(md.getValue());
                            }
                        }
                    }
                }

                serviceManager.getProcessService().writeMetadataFile(gdzfile, p);

            } catch (ReadException e) {
                Helper.setFehlerMeldung("", "ReadException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("ReadException: " + p.getTitle(), e);
            } catch (IOException e) {
                Helper.setFehlerMeldung("", "IOException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("IOException: " + p.getTitle(), e);
            } catch (InterruptedException e) {
                Helper.setFehlerMeldung("", "InterruptedException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("InterruptedException: " + p.getTitle(), e);
            } catch (PreferencesException e) {
                Helper.setFehlerMeldung("", "PreferencesException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("PreferencesException: " + p.getTitle(), e);
            } catch (UghHelperException e) {
                Helper.setFehlerMeldung("", "UghHelperException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("UghHelperException: " + p.getTitle(), e);
            } catch (Exception e) {
                Helper.setFehlerMeldung("", "Exception: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("Exception: " + p.getTitle(), e);
            }
        }
    }
    Helper.setMeldung(null, "", "------------------------------------------------------------------");
    Helper.setMeldung(null, "", "PPNs adjusted");
}

From source file:de.sub.goobi.forms.AdministrationForm.java

License:Open Source License

/**
 * Correct PPNs for statistic./*w  ww .  j  a v  a 2  s . com*/
 */
@SuppressWarnings("unchecked")
public void PPNsFuerStatistischesJahrbuchKorrigieren() throws DAOException {
    Session session = Helper.getHibernateSession();
    Criteria crit = session.createCriteria(Process.class);
    crit.add(Restrictions.eq("template", Boolean.FALSE));
    crit.createCriteria("project", "proj");
    crit.add(Restrictions.like("proj.titel", "UB-MannheimDigizeit"));

    /* alle Prozesse durchlaufen */
    for (Iterator<Process> iter = crit.list().iterator(); iter.hasNext();) {
        Process p = iter.next();
        if (serviceManager.getProcessService().getBlockedUsers(p) != null) {
            Helper.setFehlerMeldung("metadata locked: ", p.getTitle());
        } else {
            String ppn = BeanHelper.determineWorkpieceProperty(p, "PPN digital").replace("PPN ", "")
                    .replace("PPN", "");
            String jahr = BeanHelper.determineScanTemplateProperty(p, "Bandnummer");
            String ppnAufBandebene = "PPN" + ppn + "_" + jahr;

            Prefs myPrefs = serviceManager.getRulesetService().getPreferences(p.getRuleset());
            try {
                Fileformat gdzfile = serviceManager.getProcessService().readMetadataFile(p);
                DocStruct dsTop = gdzfile.getDigitalDocument().getLogicalDocStruct();
                DocStruct dsFirst = null;
                if (dsTop.getAllChildren() != null && dsTop.getAllChildren().size() > 0) {
                    dsFirst = dsTop.getAllChildren().get(0);
                }

                MetadataType mdtPpnDigital = UghHelper.getMetadataType(myPrefs, "CatalogIDDigital");

                /* digitale PPN korrigieren */
                if (dsFirst != null) {
                    List<? extends Metadata> alleMetadaten = dsFirst.getAllMetadataByType(mdtPpnDigital);
                    if (alleMetadaten == null || alleMetadaten.size() == 0) {
                        Metadata md = new Metadata(mdtPpnDigital);
                        md.setValue(ppnAufBandebene);
                        dsFirst.addMetadata(md);
                    }
                }

                /* Collections korrigieren */
                List<String> myKollektionenTitel = new ArrayList<String>();
                MetadataType coltype = UghHelper.getMetadataType(myPrefs, "singleDigCollection");
                ArrayList<Metadata> myCollections;
                if (dsTop.getAllMetadataByType(coltype) != null) {
                    myCollections = new ArrayList<Metadata>(dsTop.getAllMetadataByType(coltype));
                    if (myCollections.size() > 0) {
                        for (Iterator<Metadata> it = myCollections.iterator(); it.hasNext();) {
                            Metadata md = it.next();
                            if (myKollektionenTitel.contains(md.getValue())) {
                                dsTop.removeMetadata(md);
                            } else {
                                myKollektionenTitel.add(md.getValue());
                            }
                        }
                    }
                }
                if (dsFirst != null && dsFirst.getAllMetadataByType(coltype).size() > 0) {
                    myKollektionenTitel = new ArrayList<String>();
                    myCollections = new ArrayList<Metadata>(dsFirst.getAllMetadataByType(coltype));
                    if (myCollections.size() > 0) {
                        for (Iterator<Metadata> it = myCollections.iterator(); it.hasNext();) {
                            Metadata md = it.next();
                            if (myKollektionenTitel.contains(md.getValue())) {
                                dsFirst.removeMetadata(md);
                            } else {
                                myKollektionenTitel.add(md.getValue());
                            }
                        }
                    }
                }

                serviceManager.getProcessService().writeMetadataFile(gdzfile, p);

            } catch (ReadException e) {
                Helper.setFehlerMeldung("", "ReadException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("ReadException: " + p.getTitle(), e);
            } catch (IOException e) {
                Helper.setFehlerMeldung("", "IOException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("IOException: " + p.getTitle(), e);
            } catch (InterruptedException e) {
                Helper.setFehlerMeldung("", "InterruptedException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("InterruptedException: " + p.getTitle(), e);
            } catch (PreferencesException e) {
                Helper.setFehlerMeldung("", "PreferencesException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("PreferencesException: " + p.getTitle() + " - " + e.getMessage());
            } catch (UghHelperException e) {
                Helper.setFehlerMeldung("", "UghHelperException: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("UghHelperException: " + p.getTitle(), e);
            } catch (Exception e) {
                Helper.setFehlerMeldung("", "Exception: " + p.getTitle() + " - " + e.getMessage());
                myLogger.error("Exception: " + p.getTitle(), e);
            }
        }
    }
    Helper.setMeldung(null, "", "------------------------------------------------------------------");
    Helper.setMeldung(null, "", "PPNs adjusted");
}

From source file:de.sub.goobi.forms.AktuelleSchritteForm.java

License:Open Source License

/**
 * Take over batch.//from w ww .  j  a v  a  2 s.c o m
 *
 * @return page
 */
@SuppressWarnings("unchecked")
public String TakeOverBatch() {
    // find all steps with same batch id and step status
    List<Task> currentStepsOfBatch = new ArrayList<Task>();

    String steptitle = this.mySchritt.getTitle();
    List<Batch> batches = serviceManager.getProcessService().getBatchesByType(mySchritt.getProcess(),
            Type.LOGISTIC);
    if (batches.size() > 1) {
        Helper.setFehlerMeldung("multipleBatchesAssigned");
        return "";
    }
    if (batches.size() != 0) {
        Integer batchNumber = batches.iterator().next().getId();
        // only steps with same title
        Session session = Helper.getHibernateSession();
        Criteria crit = session.createCriteria(Task.class);
        crit.add(Restrictions.eq("title", steptitle));
        // only steps with same batchid
        crit.createCriteria("process", "proc");
        crit.createCriteria("proc.batches", "bat");
        crit.add(Restrictions.eq("bat.id", batchNumber));
        crit.add(Restrictions.eq("batchStep", true));

        currentStepsOfBatch = crit.list();
    } else {
        return SchrittDurchBenutzerUebernehmen();
    }
    // if only one step is assigned for this batch, use the single

    // Helper.setMeldung("found " + currentStepsOfBatch.size() + " elements
    // in batch");
    if (currentStepsOfBatch.size() == 0) {
        return "";
    }
    if (currentStepsOfBatch.size() == 1) {
        return SchrittDurchBenutzerUebernehmen();
    }

    for (Task s : currentStepsOfBatch) {
        if (s.getProcessingStatusEnum().equals(TaskStatus.OPEN)) {
            s.setProcessingStatusEnum(TaskStatus.INWORK);
            s.setEditTypeEnum(TaskEditType.MANUAL_MULTI);
            s.setProcessingTime(new Date());
            User ben = (User) Helper.getManagedBeanValue("#{LoginForm.myBenutzer}");
            if (ben != null) {
                s.setProcessingUser(ben);
            }
            if (s.getProcessingBegin() == null) {
                Date myDate = new Date();
                s.setProcessingBegin(myDate);
            }
            serviceManager.getProcessService().getHistoryInitialized(s.getProcess())
                    .add(new History(s.getProcessingBegin(), s.getOrdering().doubleValue(), s.getTitle(),
                            HistoryType.taskInWork, s.getProcess()));

            if (s.isTypeImagesRead() || s.isTypeImagesWrite()) {
                try {
                    new File(serviceManager.getProcessService().getImagesOrigDirectory(false, s.getProcess()));
                } catch (Exception e1) {

                }
                s.setProcessingTime(new Date());

                if (ben != null) {
                    s.setProcessingUser(ben);
                }
                this.myDav.DownloadToHome(s.getProcess(), s.getId(), !s.isTypeImagesWrite());

            }
        }

        try {
            this.serviceManager.getProcessService().save(s.getProcess());
        } catch (DAOException e) {
            Helper.setFehlerMeldung(Helper.getTranslation("stepSaveError"), e);
            myLogger.error("task couldn't get saved", e);
        } catch (IOException | ResponseException e) {
            myLogger.error("task couldn't get inserted", e);
        }
    }

    this.setBatchHelper(new BatchStepHelper(currentStepsOfBatch));
    return "BatchesEdit";
}

From source file:de.sub.goobi.forms.AktuelleSchritteForm.java

License:Open Source License

/**
 * Edit batch.//from   w w  w . j  a  v  a 2  s  .  c  om
 *
 * @return page
 */
@SuppressWarnings("unchecked")
public String BatchesEdit() {
    // find all steps with same batch id and step status
    List<Task> currentStepsOfBatch = new ArrayList<Task>();

    String steptitle = this.mySchritt.getTitle();
    List<Batch> batches = serviceManager.getProcessService().getBatchesByType(mySchritt.getProcess(),
            Type.LOGISTIC);
    if (batches.size() > 1) {
        Helper.setFehlerMeldung("multipleBatchesAssigned");
        return "";
    }
    if (batches.size() != 0) {
        Integer batchNumber = batches.iterator().next().getId();
        // only steps with same title

        Session session = Helper.getHibernateSession();
        Criteria crit = session.createCriteria(Task.class);
        crit.add(Restrictions.eq("title", steptitle));
        // only steps with same batchid
        crit.createCriteria("process", "proc");
        crit.createCriteria("proc.batches", "bat");
        crit.add(Restrictions.eq("bat.id", batchNumber));
        crit.add(Restrictions.eq("batchStep", true));

        currentStepsOfBatch = crit.list();
    } else {
        return "AktuelleSchritteBearbeiten";
    }
    // if only one step is assigned for this batch, use the single

    // Helper.setMeldung("found " + currentStepsOfBatch.size() + " elements
    // in batch");

    if (currentStepsOfBatch.size() == 1) {
        return "AktuelleSchritteBearbeiten";
    }
    this.setBatchHelper(new BatchStepHelper(currentStepsOfBatch));
    return "BatchesEdit";
}

From source file:de.sub.goobi.forms.ProzessverwaltungForm.java

License:Open Source License

/**
 * Anzeige der Sammelbnde filtern./*from w ww. j  av a2  s. c  o m*/
 */
public String FilterAlleStart() {
    this.statisticsManager = null;
    this.myAnzahlList = null;
    /*
     * Filter fr die Auflistung anwenden
     */
    try {

        // ... Criteria will persist, because it gets passed on to the
        // PageObject
        // but in order to use the extended functions of the
        // UserDefinedFilter
        // for statistics, we will have to hold a reference to the instance
        // of UserDefinedFilter
        this.myFilteredDataSource = new UserDefinedFilter(this.filter);

        // set observable to replace helper.setMessage
        this.myFilteredDataSource.getObservable().addObserver(new Helper().createObserver());

        // // calling the criteria as the result of the filter
        Criteria crit = this.myFilteredDataSource.getCriteria();

        // first manipulation of the created criteria

        /* nur die Vorlagen oder alles */
        if (this.modusAnzeige.equals("vorlagen")) {
            crit.add(Restrictions.eq("template", Boolean.TRUE));
        } else {
            crit.add(Restrictions.eq("template", Boolean.FALSE));
        }
        /* alle Suchparameter miteinander kombinieren */
        if (!this.showClosedProcesses && !this.modusAnzeige.equals("vorlagen")) {
            crit.add(Restrictions.not(Restrictions.eq("sortHelperStatus", "100000000")));
        }

        if (!this.showArchivedProjects) {
            crit.createCriteria("project", "proj");
            crit.add(Restrictions.not(Restrictions.eq("proj.projectIsArchived", true)));
            sortList(crit, false);
        } else {
            /* noch sortieren */
            sortList(crit, true);
        }

        this.page = new Page(crit, 0);
    } catch (HibernateException he) {
        Helper.setFehlerMeldung("fehlerBeimEinlesen", he.getMessage());
        return "";
    } catch (NumberFormatException ne) {
        Helper.setFehlerMeldung("Falsche Suchparameter angegeben", ne.getMessage());
        return "";
    } catch (UnsupportedOperationException e) {
        logger.error(e);
    }

    return "ProzessverwaltungAlle";
}

From source file:de.sub.goobi.forms.ProzessverwaltungForm.java

License:Open Source License

private void sortList(Criteria inCrit, boolean addCriteria) {
    Order order = Order.asc("title");
    if (this.sortierung.equals("titelAsc")) {
        order = Order.asc("title");
    }//from w  ww.  ja  v a  2 s  . co  m
    if (this.sortierung.equals("titelDesc")) {
        order = Order.desc("title");
    }
    if (this.sortierung.equals("batchAsc")) {
        order = Order.asc("batchID");
    }
    if (this.sortierung.equals("batchDesc")) {
        order = Order.desc("batchID");
    }

    if (this.sortierung.equals("projektAsc")) {
        if (addCriteria) {
            inCrit.createCriteria("project", "proj");
        }
        order = Order.asc("proj.title");
    }

    if (this.sortierung.equals("projektDesc")) {
        if (addCriteria) {
            inCrit.createCriteria("project", "proj");
        }
        order = Order.desc("proj.title");
    }

    if (this.sortierung.equals("vorgangsdatumAsc")) {
        order = Order.asc("creationDate");
    }
    if (this.sortierung.equals("vorgangsdatumDesc")) {
        order = Order.desc("creationDate");
    }

    if (this.sortierung.equals("fortschrittAsc")) {
        order = Order.asc("sortHelperStatus");
    }
    if (this.sortierung.equals("fortschrittDesc")) {
        order = Order.desc("sortHelperStatus");
    }

    inCrit.addOrder(order);
}