List of usage examples for org.hibernate.criterion Restrictions not
public static Criterion not(Criterion expression)
From source file:org.gluewine.persistence_jpa_hibernate.impl.HibernateTransactionalSessionImpl.java
License:Apache License
@Override public Criteria createCriteria(Class<?> cl, Filter filter) { Criteria cr = createCriteria(cl);/*w w w. j a v a2 s . c om*/ for (FilterLine line : filter.getLines()) { switch (line.getOperator()) { case CONTAINS: cr.add(Restrictions.like(line.getFieldName(), "%" + line.getValue() + "%")); break; case DOES_NOT_CONTAIN: cr.add(Restrictions.not(Restrictions.like(line.getFieldName(), "%" + line.getValue() + "%"))); break; case DOES_NOT_ICONTAIN: cr.add(Restrictions.not(Restrictions.ilike(line.getFieldName(), "%" + line.getValue() + "%"))); break; case EQUALS: cr.add(Restrictions.eq(line.getFieldName(), line.getValue())); break; case GREATER_OR_EQUAL_THAN: cr.add(Restrictions.ge(line.getFieldName(), line.getValue())); break; case GREATER_THAN: cr.add(Restrictions.gt(line.getFieldName(), line.getValue())); break; case ICONTAINS: cr.add(Restrictions.ilike(line.getFieldName(), "%" + line.getValue() + "%")); break; case LESS_OR_EQUAL_THAN: cr.add(Restrictions.le(line.getFieldName(), line.getValue())); break; case LESS_THAN: cr.add(Restrictions.lt(line.getFieldName(), line.getValue())); break; case NOT_EQUALS: cr.add(Restrictions.ne(line.getFieldName(), line.getValue())); break; case ISNULL: cr.add(Restrictions.isNull(line.getFieldName())); break; case NOTNULL: cr.add(Restrictions.isNotNull(line.getFieldName())); break; default: break; } } for (SortLine sort : filter.getSortLines()) { if (sort.isAscending()) cr.addOrder(Property.forName(sort.getField()).asc()); else cr.addOrder(Property.forName(sort.getField()).desc()); } if (filter.getLimit() != 0) cr.setMaxResults(filter.getLimit()); if (filter.getOffset() != 0) cr.setFirstResult(filter.getOffset()); return cr; }
From source file:org.goobi.production.flow.helper.SearchResultGeneration.java
License:Open Source License
/** * Get result.//from ww w . jav a 2 s . c o m * * @return HSSFWorkbook */ @SuppressWarnings("deprecation") public HSSFWorkbook getResult() { IEvaluableFilter myFilteredDataSource = new UserDefinedFilter(this.filter); Criteria crit = myFilteredDataSource.getCriteria(); crit.add(Restrictions.eq("istTemplate", Boolean.FALSE)); if (!this.showClosedProcesses) { crit.add(Restrictions.not(Restrictions.eq("sortHelperStatus", "100000000"))); } if (!this.showArchivedProjects) { crit.createCriteria("projekt", "proj"); crit.add(Restrictions.not(Restrictions.eq("proj.projectIsArchived", true))); } else { crit.createCriteria("projekt", "proj"); } Order order = Order.asc("titel"); crit.addOrder(order); @SuppressWarnings("unchecked") List<Process> pl = crit.setFirstResult(0).setMaxResults(Integer.MAX_VALUE).list(); HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet("Search results"); HSSFRow title = sheet.createRow(0); HSSFCell titleCell1 = title.createCell(0); titleCell1.setCellValue(this.filter); HSSFCell titleCell2 = title.createCell(1); titleCell2.setCellValue(""); HSSFCell titleCell3 = title.createCell(2); titleCell3.setCellValue(""); HSSFCell titleCell4 = title.createCell(3); titleCell4.setCellValue(""); HSSFCell titleCell5 = title.createCell(4); titleCell5.setCellValue(""); HSSFCell titleCell6 = title.createCell(5); titleCell6.setCellValue(""); HSSFCell titleCell7 = title.createCell(6); titleCell7.setCellValue(""); HSSFCell titleCell8 = title.createCell(7); titleCell8.setCellValue(""); HSSFCell titleCell9 = title.createCell(8); titleCell9.setCellValue(""); HSSFRow row0 = sheet.createRow(1); HSSFCell headercell0 = row0.createCell(0); headercell0.setCellValue(Helper.getTranslation("title")); HSSFCell headercell1 = row0.createCell(1); headercell1.setCellValue(Helper.getTranslation("ID")); HSSFCell headercell2 = row0.createCell(2); headercell2.setCellValue(Helper.getTranslation("Datum")); HSSFCell headercell3 = row0.createCell(3); headercell3.setCellValue(Helper.getTranslation("CountImages")); HSSFCell headercell4 = row0.createCell(4); headercell4.setCellValue(Helper.getTranslation("CountMetadata")); HSSFCell headercell5 = row0.createCell(5); headercell5.setCellValue(Helper.getTranslation("Project")); HSSFCell headercell6 = row0.createCell(6); headercell6.setCellValue(Helper.getTranslation("Status")); HSSFCell headercell7 = row0.createCell(7); headercell7.setCellValue(Helper.getTranslation("AltRefNo")); HSSFCell headercell8 = row0.createCell(8); headercell8.setCellValue(Helper.getTranslation("b-number")); int rowcounter = 2; for (Process p : pl) { HSSFRow row = sheet.createRow(rowcounter); HSSFCell cell0 = row.createCell(0); cell0.setCellValue(p.getTitle()); HSSFCell cell1 = row.createCell(1); cell1.setCellValue(p.getId()); HSSFCell cell2 = row.createCell(2); cell2.setCellValue(p.getCreationDate().toGMTString()); HSSFCell cell3 = row.createCell(3); cell3.setCellValue(p.getSortHelperImages()); HSSFCell cell4 = row.createCell(4); cell4.setCellValue(p.getSortHelperDocstructs()); HSSFCell cell5 = row.createCell(5); cell5.setCellValue(p.getProject().getTitle()); HSSFCell cell6 = row.createCell(6); cell6.setCellValue(p.getSortHelperStatus().substring(0, 3) + " / " + p.getSortHelperStatus().substring(3, 6) + " / " + p.getSortHelperStatus().substring(6)); HSSFCell cell7 = row.createCell(7); cell7.setCellValue(""); HSSFCell cell8 = row.createCell(8); cell8.setCellValue(""); if (p.getProperties().size() > 0) { for (ProcessProperty pe : p.getProperties()) { if (pe.getTitle().equals("AltRefNo")) { cell7.setCellValue(pe.getValue()); } else if (pe.getTitle().equals("b-number")) { cell8.setCellValue(pe.getValue()); } } } rowcounter++; } return wb; }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
/** * Filter processes for done steps range. * * @param con//from w ww . j ava 2 s. c o m * Conjuction object * @param parameters * String * @param inStatus * TaskStatus object * @param negate * boolean * @param prefix * {@link TaskStatus} of searched step */ protected static void filterStepRange(Conjunction con, String parameters, TaskStatus inStatus, boolean negate, String prefix) { if (!negate) { con.add(Restrictions.and( Restrictions.and(Restrictions.ge(prefix + "ordering", FilterHelper.getStepStart(parameters)), Restrictions.le(prefix + "ordering", FilterHelper.getStepEnd(parameters))), Restrictions.eq(prefix + "processingStatus", inStatus.getValue()))); } else { con.add(Restrictions.not(Restrictions.and( Restrictions.and(Restrictions.ge(prefix + "ordering", FilterHelper.getStepStart(parameters)), Restrictions.le(prefix + "ordering", FilterHelper.getStepEnd(parameters))), Restrictions.eq(prefix + "processingStatus", inStatus.getValue())))); } }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
/** * Filter processes for steps name with given status. * * @param inStatus//from w w w . ja v a2 s.co m * {@link TaskStatus} of searched step * @param parameters * part of filter string to use */ protected static void filterStepName(Conjunction con, String parameters, TaskStatus inStatus, boolean negate, String prefix) { if (con == null) { con = Restrictions.conjunction(); } if (!negate) { con.add(Restrictions.and(Restrictions.like(prefix + "title", "%" + parameters + "%"), Restrictions.eq(prefix + "processingStatus", inStatus.getValue()))); } else { con.add(Restrictions.not(Restrictions.and(Restrictions.like(prefix + "title", "%" + parameters + "%"), Restrictions.eq(prefix + "processingStatus", inStatus.getValue())))); } }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
/** * Filter processes for done steps min./* w ww . j a va2s . c o m*/ * * @param parameters * part of filter string to use * @param inStatus * {@link TaskStatus} of searched step */ protected static void filterStepMin(Conjunction con, String parameters, TaskStatus inStatus, boolean negate, String prefix) { if (con == null) { con = Restrictions.conjunction(); } if (!negate) { con.add(Restrictions.and(Restrictions.ge(prefix + "ordering", FilterHelper.getStepStart(parameters)), Restrictions.eq(prefix + "processingStatus", inStatus.getValue()))); } else { con.add(Restrictions.not( Restrictions.and(Restrictions.ge(prefix + "ordering", FilterHelper.getStepStart(parameters)), Restrictions.eq(prefix + "processingStatus", inStatus.getValue())))); } }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
/** * Filter processes for done steps max.// w w w . j a v a2s. co m * * @param parameters * part of filter string to use * @param inStatus * {@link TaskStatus} of searched step */ protected static void filterStepMax(Conjunction con, String parameters, TaskStatus inStatus, boolean negate, String prefix) { if (con == null) { con = Restrictions.conjunction(); } if (!negate) { con.add(Restrictions.and(Restrictions.le(prefix + "ordering", FilterHelper.getStepEnd(parameters)), Restrictions.eq(prefix + "processingStatus", inStatus.getValue()))); } else { con.add(Restrictions .not(Restrictions.and(Restrictions.le(prefix + "ordering", FilterHelper.getStepEnd(parameters)), Restrictions.eq(prefix + "processingStatus", inStatus.getValue())))); } }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
/** * Filter processes for done steps exact. * * @param parameters//from w w w .j a va 2 s.c om * part of filter string to use * @param inStatus * {@link TaskStatus} of searched step */ protected static void filterStepExact(Conjunction con, String parameters, TaskStatus inStatus, boolean negate, String prefix) { if (!negate) { con.add(Restrictions.and(Restrictions.eq(prefix + "ordering", FilterHelper.getStepStart(parameters)), Restrictions.eq(prefix + "processingStatus", inStatus.getValue()))); } else { con.add(Restrictions.not( Restrictions.and(Restrictions.eq(prefix + "ordering", FilterHelper.getStepStart(parameters)), Restrictions.eq(prefix + "processingStatus", inStatus.getValue())))); } }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
/** * Filter processes by project./* w w w. j a va 2 s .c o m*/ * * @param tok * part of filter string to use */ protected static void filterProject(Conjunction con, String tok, boolean negate) { /* filter according to linked project */ if (!negate) { con.add(Restrictions.like("project.title", "%" + tok.substring(tok.indexOf(":") + 1) + "%")); } else { con.add(Restrictions .not(Restrictions.like("project.title", "%" + tok.substring(tok.indexOf(":") + 1) + "%"))); } }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
/** * Filter processes by scan template.//from www. jav a 2s. c o m * * @param tok * part of filter string to use */ protected static void filterScanTemplate(Conjunction con, String tok, boolean negate) { /* Filtering by signature */ String[] ts = tok.substring(tok.indexOf(":") + 1).split(":"); if (!negate) { if (ts.length > 1) { con.add(Restrictions.and(Restrictions.like("vorleig.value", "%" + ts[1] + "%"), Restrictions.like("vorleig.title", "%" + ts[0] + "%"))); } else { con.add(Restrictions.like("vorleig.value", "%" + ts[0] + "%")); } } else { if (ts.length > 1) { con.add(Restrictions.not(Restrictions.and(Restrictions.like("vorleig.value", "%" + ts[1] + "%"), Restrictions.like("vorleig.title", "%" + ts[0] + "%")))); } else { con.add(Restrictions.not(Restrictions.like("vorleig.value", "%" + ts[0] + "%"))); } } }
From source file:org.goobi.production.flow.statistics.hibernate.FilterHelper.java
License:Open Source License
protected static void filterProcessProperty(Conjunction con, String tok, boolean negate) { /* Filtering by signature */ String[] ts = tok.substring(tok.indexOf(":") + 1).split(":"); if (!negate) { if (ts.length > 1) { con.add(Restrictions.and(Restrictions.like("prozesseig.value", "%" + ts[1] + "%"), Restrictions.like("prozesseig.title", "%" + ts[0] + "%"))); } else {// w w w. ja v a 2 s .co m con.add(Restrictions.like("prozesseig.value", "%" + ts[0] + "%")); } } else { if (ts.length > 1) { con.add(Restrictions.not(Restrictions.and(Restrictions.like("prozesseig.value", "%" + ts[1] + "%"), Restrictions.like("prozesseig.title", "%" + ts[0] + "%")))); } else { con.add(Restrictions.not(Restrictions.like("prozesseig.value", "%" + ts[0] + "%"))); } } }