Example usage for org.hibernate.type IntegerType ZERO

List of usage examples for org.hibernate.type IntegerType ZERO

Introduction

In this page you can find the example usage for org.hibernate.type IntegerType ZERO.

Prototype

Integer ZERO

To view the source code for org.hibernate.type IntegerType ZERO.

Click Source Link

Usage

From source file:br.com.tpartner.persistence.model.EducationalResourceStats.java

public EducationalResourceStats() {
    maxTimeSpent = IntegerType.ZERO;
    minTimeSpent = IntegerType.ZERO;//from   w ww.  j a  v a  2  s. com
    firstQuartile = IntegerType.ZERO;
    thirdQuartile = IntegerType.ZERO;
    interQuartileRange = IntegerType.ZERO;
    totalInteractions = IntegerType.ZERO;
    timeSpentMedian = IntegerType.ZERO;
    timeSpentAverage = DoubleType.ZERO;
    resourceInteractions = new ArrayList();
    outliersInteractions = new ArrayList();
    generatedTime = new Date(IntegerType.ZERO);
    educationalResource = new EducationalResource();
}

From source file:br.com.tpartner.persistence.model.EducationalResourceStats.java

public EducationalResourceStats(EducationalResource educationalResource,
        ResourceInteractionCRUD resourceInteractionDAO) {

    generatedTime = new Date();

    this.educationalResource = educationalResource;

    resourceInteractions = resourceInteractionDAO.findByEducationalResource(educationalResource);

    totalInteractions = resourceInteractions.size();
    Collections.sort(resourceInteractions, new Comparator<ResourceInteraction>() {
        public int compare(ResourceInteraction o1, ResourceInteraction o2) {
            return o1.getTimeSpent() - o2.getTimeSpent();
        }/*from ww  w  . j a v  a2 s.  c  o  m*/
    });

    firstQuartile = new Double(0.25 * totalInteractions).intValue() + 1;
    thirdQuartile = new Double(0.75 * totalInteractions).intValue() + 1;
    interQuartileRange = thirdQuartile - firstQuartile;

    if (totalInteractions % 2 == IntegerType.ZERO) {
        timeSpentMedian = resourceInteractions.get(totalInteractions / 2).getTimeSpent();
        timeSpentMedian += resourceInteractions.get(totalInteractions / 2 - 1).getTimeSpent();
        timeSpentMedian /= 2;
    } else {
        timeSpentMedian = resourceInteractions.get(totalInteractions / 2).getTimeSpent();
    }

    minTimeSpent = resourceInteractions.get(IntegerType.ZERO).getTimeSpent();
    maxTimeSpent = resourceInteractions.get(totalInteractions - 1).getTimeSpent();

    timeSpentAverage = DoubleType.ZERO;
    for (ResourceInteraction resourceInteraction : resourceInteractions) {
        timeSpentAverage += resourceInteraction.getTimeSpent();
    }
    timeSpentAverage /= totalInteractions;

    outliersInteractions = new ArrayList<ResourceInteraction>();
    for (int i = 0; i < (firstQuartile - (1.5 * interQuartileRange)); i++) {
        outliersInteractions.add(resourceInteractions.get(i));
    }
    for (int i = (totalInteractions - 1); i > (thirdQuartile + (1.5 * interQuartileRange)); i++) {
        outliersInteractions.add(resourceInteractions.get(i));
    }

}