Package org.hibernate.criterion

Examples of org.hibernate.criterion.ProjectionList


    dzialService.deleteById(generatedId);
  }
 
  @Test
  public void findByParamsProjections() throws Exception{
    ProjectionList list = Projections.projectionList();
    list.add(Projections.property(Dzial.PROPERTY_ID));
    list.add(Projections.property(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_IMIE));
    list.add(Projections.property(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_OBJECT_STANOWSKO+"."+Stanowisko.PROPERTY_NAZWA));
    dzialService.findByParams(list);
  }
View Full Code Here


    List<Dzial> dList = dzialService.findByParams(list);
  }
 
  @Test
  public void findByParamsProjectionsCriteria() throws Exception{
    ProjectionList listProjections = Projections.projectionList();
    listProjections.add(Projections.property(Dzial.PROPERTY_ID));
    listProjections.add(Projections.property(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_IMIE));
    listProjections.add(Projections.property(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_OBJECT_STANOWSKO+"."+Stanowisko.PROPERTY_NAZWA));
   
    List<Criterion> listCriterions = new ArrayList<Criterion>();
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_NAZWA_DZIALU));
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_ID));
   
View Full Code Here

   
    dzialService.findByParams(listProjections, listCriterions);
  }
  @Test
  public void findByParamsProjectionsCriteriaOrder() throws Exception{
    ProjectionList listProjections = Projections.projectionList();
    listProjections.add(Projections.property(Dzial.PROPERTY_ID));
    listProjections.add(Projections.property(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_IMIE));
    listProjections.add(Projections.property(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_OBJECT_STANOWSKO+"."+Stanowisko.PROPERTY_NAZWA));
   
    List<Criterion> listCriterions = new ArrayList<Criterion>();
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_NAZWA_DZIALU));
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_ID));
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_OBJECT_STANOWSKO+"."+Stanowisko.PROPERTY_ID));
View Full Code Here

    dzialService.findByParams(listProjections, listCriterions, listOrders);
  }
 
  @Test
  public void findByParamsProjectionsCriteriaOrderStartIndexRowAmount() throws Exception{
    ProjectionList listProjections = Projections.projectionList();
    listProjections.add(Projections.property(Dzial.PROPERTY_ID));
   
    List<Criterion> listCriterions = new ArrayList<Criterion>();
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_NAZWA_DZIALU));
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_ID));
    listCriterions.add(Restrictions.isNotNull(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_OBJECT_STANOWSKO+"."+Stanowisko.PROPERTY_ID));
View Full Code Here

    dzialService.getRowCount(list);
  }

  @Test
  public void getRowCountProjectionCriteria() throws Exception{
    ProjectionList listProjections = Projections.projectionList();
    listProjections.add(Projections.distinct(Projections.property(Dzial.PROPERTY_NAZWA_DZIALU)));
 
    List<Criterion> list = new ArrayList<Criterion>();
    list.add(Restrictions.isNotNull(Dzial.PROPERTY_NAZWA_DZIALU));
    list.add(Restrictions.isNotNull(Dzial.PROPERTY_OBJECT_PRACOWNIKS+"."+Pracownik.PROPERTY_ID));
    dzialService.getRowCount(listProjections, list);
View Full Code Here

    crit.addOrder(Order.asc("reihenfolge"));

    crit.add(Restrictions.eq("proc.istTemplate", Boolean.FALSE));
    crit.add(Restrictions.eq("proc.projekt", inProject));

    ProjectionList proList = Projections.projectionList();

    proList.add(Projections.property("titel"));
    proList.add(Projections.property("bearbeitungsstatus"));
    proList.add(Projections.sum("proc.sortHelperImages"));
    proList.add(Projections.count("id"));
//    proList.add(Projections.groupProperty(("reihenfolge")));
   
    proList.add(Projections.groupProperty(("titel")));
    proList.add(Projections.groupProperty(("bearbeitungsstatus")));

    crit.setProjection(proList);

    List list = crit.list();
View Full Code Here

   */

  @SuppressWarnings("rawtypes")
  public void GenerateValuesForStatistics() {
    Criteria crit = Helper.getHibernateSession().createCriteria(Prozess.class).add(Restrictions.eq("projekt", this.myProjekt));
    ProjectionList pl = Projections.projectionList();
    pl.add(Projections.sum("sortHelperImages"));
    pl.add(Projections.count("sortHelperImages"));
    crit.setProjection(pl);
    List list = crit.list();
    Long images = 0l;
    Long volumes = 0l;
    for (Object obj : list) {
View Full Code Here

    } else {
      throw new UnsupportedOperationException(
          "This implementation of IStatisticalQuestion needs an IDataSource for method getDataSets()");
    }

    ProjectionList proj = Projections.projectionList();
    proj.add(Projections.count("id"));
    proj.add(Projections.groupProperty("proj.titel"));

    Criteria crit;

    if (originalFilter instanceof UserDefinedFilter) {
      crit = new UserDefinedFilter(originalFilter.getIDList())
View Full Code Here

    Criteria critTotals = session.createCriteria(Prozess.class, "proc");
    critTotals.add(Restrictions.eq("proc.istTemplate", Boolean.FALSE));
    critTotals.add(Restrictions.eq("proc.projekt", inProj));

    ProjectionList proList = Projections.projectionList();

    proList.add(Projections.count("proc.id"));

    critTotals.setProjection(proList);

    List<Object> list = critTotals.list();

    for (Object obj : list) {
      Object[] row = (Object[]) obj;

      totalNumberOfProc = (Long) row[FieldList.totalProcessCount.fieldLocation];
    }

    proList = null;
    list = null;

 
    Criteria critSteps = session.createCriteria(Schritt.class);

    critSteps.createCriteria("prozess", "proc");
    critSteps.addOrder(Order.asc("reihenfolge"));

    critSteps.add(Restrictions.eq("proc.istTemplate", Boolean.FALSE));
    critSteps.add(Restrictions.eq("proc.projekt", inProj));

    proList = Projections.projectionList();

    proList.add(Projections.groupProperty(("titel")));
    proList.add(Projections.count("id"));
    proList.add(Projections.avg("reihenfolge"));

   

    critSteps.setProjection(proList);
View Full Code Here

    Criteria critTotals = session.createCriteria(Prozess.class, "proc");
    critTotals.add(Restrictions.eq("proc.istTemplate", Boolean.FALSE));
    critTotals.add(Restrictions.eq("proc.projekt", project));

    ProjectionList proList = Projections.projectionList();

    proList.add(Projections.count("proc.id"));
    proList.add(Projections.sum("proc.sortHelperImages"));

    critTotals.setProjection(proList);

    List<Object> list = critTotals.list();

    for (Object obj : list) {
      Object[] row = (Object[]) obj;

      totalNumberOfProc = (Long) row[FieldList.totalProcessCount.fieldLocation];
      totalNumberOfImages = (Long) row[FieldList.totalImageCount.fieldLocation];
      ;
    }

    proList = null;
    list = null;

 

    Criteria critSteps = session.createCriteria(Schritt.class);

    critSteps.createCriteria("prozess", "proc");
    critSteps.addOrder(Order.asc("reihenfolge"));

    critSteps.add(Restrictions.eq("proc.istTemplate", Boolean.FALSE));
    critSteps.add(Restrictions.eq("proc.projekt", project));

    proList = Projections.projectionList();

    proList.add(Projections.groupProperty(("titel")));
    proList.add(Projections.count("id"));
    proList.add(Projections.avg("reihenfolge"));

 
    critSteps.setProjection(proList);

    // now we have to discriminate the hits where the max number of hits doesn't reach numberOfProcs
    // and extract a workflow, which is the workflow common for all processes according to its titel
    // the position will be calculated by the average of 'reihenfolge' of steps

    list = critSteps.list();

    String title;
    Double averageStepOrder;
    Long numberOfSteps;
    Long numberOfImages;

    List<StepInformation> workFlow = new ArrayList<StepInformation>();

    for (Object obj : list) {
      Object[] row = (Object[]) obj;

      title = (String) (row[FieldList.stepName.fieldLocation]);
      numberOfSteps = (Long) (row[FieldList.stepCount.fieldLocation]);
      averageStepOrder = (Double) (row[FieldList.stepOrder.fieldLocation]);

      // in this step we only take the steps which are present in each of the workflows
      if (numberOfSteps.equals(totalNumberOfProc)) {
        StepInformation newStep = new StepInformation(title, averageStepOrder);
        newStep.setNumberOfTotalImages(totalNumberOfImages.intValue());
        newStep.setNumberOfTotalSteps(totalNumberOfProc.intValue());
        workFlow.add(newStep);
      }
    }

    Criteria critStepDone = session.createCriteria(Schritt.class, "step");

    critStepDone.createCriteria("prozess", "proc");

    critStepDone.add(Restrictions.eq("step.bearbeitungsstatus", StepStatus.DONE.getValue()));
    critStepDone.add(Restrictions.eq("proc.istTemplate", Boolean.FALSE));
    critStepDone.add(Restrictions.eq("proc.projekt", project));

    ProjectionList proCount = Projections.projectionList();

    proCount.add(Projections.groupProperty(("step.titel")));
    proCount.add(Projections.count("proc.id"));
    proCount.add(Projections.sum("proc.sortHelperImages"));

    critStepDone.setProjection(proCount);

    list = critStepDone.list();
View Full Code Here

TOP

Related Classes of org.hibernate.criterion.ProjectionList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.