Exemple #1
0
 @Override
 public int compare(Criterion o1, Criterion o2) {
     if (o1.getType().getName() == null) {
         return 1;
     }
     if (o2.getType().getName() == null) {
         return -1;
     }
     return o1.getType().getName().toLowerCase()
             .compareTo(o2.getType().getName().toLowerCase());
 }
 public static ResourceEnum inferType(Collection<? extends Criterion> criterions) {
   if (criterions.isEmpty()) {
     return ResourceEnum.WORKER;
   }
   Criterion first = criterions.iterator().next();
   return first.getType().getResource();
 }
Exemple #3
0
  @Test
  public void ifItsDifferentThereIsOther() {
    Criterion c =
        transactionService.runOnTransaction(
            new IOnTransaction<Criterion>() {

              @Override
              public Criterion execute() {
                return givenASavedCriterionWithAnExistentType();
              }
            });
    Criterion copy = Criterion.create(c.getName(), c.getType());
    assertTrue(criterionDAO.thereIsOtherWithSameNameAndType(copy));
  }
 private void reattachCriterion(Criterion criterion) {
     criterionDAO.reattachUnmodifiedEntity(criterion);
     criterion.getName();
     reattachCriterionType(criterion.getType());
 }
 private void initializeCriterion(Criterion criterion) {
     criterionDAO.reattach(criterion);
     Hibernate.initialize(criterion.getType());
 }
Exemple #6
0
 private Criterion anotherCriterionWithSameNameAndType(Criterion c) {
   return Criterion.create(c.getName(), c.getType());
 }
Exemple #7
0
 public boolean isEquivalent(Criterion other) {
     return new EqualsBuilder().append(getName(), other.getName())
             .append(getType(), other.getType()).isEquals();
 }