public DocumentCategoryConfigShortVo save(DocumentCategoryConfigShortVo record) throws StaleObjectException, ForeignKeyViolationException { if (!record.isValidated()) throw new DomainRuntimeException("Unable to save a record that is not validated"); DomainFactory factory = getDomainFactory(); if (!record.getID_DocumentCategoryConfigIsNotNull()) { String count = "select count(dcc.id) from DocumentCategoryConfig as dcc left join dcc.template as tem where (tem.id = :templateId)"; long configs = factory.countWithHQL(count, new String[] { "templateId" }, new Object[]{record.getTemplate().getID_TemplateBo()}); if (configs > 0) { throw new StaleObjectException(null); } } DocumentCategoryConfig dccDO = DocumentCategoryConfigShortVoAssembler.extractDocumentCategoryConfig(factory, record); factory.save(dccDO); return DocumentCategoryConfigShortVoAssembler.create(dccDO); }
public DocumentCategoryConfigShortVo getDocCatConfig(TemplateBoRefVo template) { if (!template.getID_TemplateBoIsNotNull()) throw new DomainRuntimeException("Unable to retrive document category config for template with null id!"); String hql = "select dcc from DocumentCategoryConfig as dcc left join dcc.template as temp where dcc.isRIE is null and temp.id=:idTemp"; List<?> dos = getDomainFactory().find(hql, "idTemp", template.getID_TemplateBo()); if (dos == null || dos.size() == 0) return null; return DocumentCategoryConfigShortVoAssembler.createDocumentCategoryConfigShortVoCollectionFromDocumentCategoryConfig(dos).get(0); }
public DocumentCategoryConfigShortVoCollection listDocCateConfig(DocumentCategory docCat) { String hql = "from DocumentCategoryConfig as dcc where (dcc.category.id = :catId) order by upper(dcc.template.name) asc";// WDEV-13654 List<?> domObjs = getDomainFactory().find(hql, new String[] { "catId" }, new Object[] { docCat.getId() }); if (domObjs == null || domObjs.size() == 0) return null; return DocumentCategoryConfigShortVoAssembler.createDocumentCategoryConfigShortVoCollectionFromDocumentCategoryConfig(domObjs); }
public DocumentCategoryConfigShortVoCollection saveAll(DocumentCategoryConfigShortVoCollection oldCats, DocumentCategoryConfigShortVoCollection newCats) throws StaleObjectException, ForeignKeyViolationException { DomainFactory df = getDomainFactory(); if (oldCats != null) { if (newCats != null) for (int i = oldCats.size() - 1; i >= 0; i--) { if (newCats.contains(oldCats.get(i))) { oldCats.remove(i); } } for (int i = 0; i < oldCats.size(); i++) { df.delete(DocumentCategoryConfigShortVoAssembler.extractDocumentCategoryConfig(df, oldCats.get(i))); } } if (newCats == null) return null; DocumentCategoryConfigShortVoCollection result = new DocumentCategoryConfigShortVoCollection(); for (int i = 0; i < newCats.size(); i++) { result.add(save(newCats.get(i))); } return result; }
public DocumentCategoryConfigShortVoCollection searchReports(String templateName, String listOfMandatorySeeds, DocumentCategory documentType, Specialty specialty) { DomainFactory factory = getDomainFactory(); ArrayList<String> markers = new ArrayList<String>(); ArrayList<Object> values = new ArrayList<Object>(); String subHql = ""; if(listOfMandatorySeeds != null && listOfMandatorySeeds.length() > 0) { subHql = " and r21.bOName not in (" + listOfMandatorySeeds + ")"; } String mainHql = "select d from DocumentCategoryConfig as d left join d.template as t left join t.report as r"; String whereHql = " where t.id not in (select t11.id from TemplateBo as t11 left join t11.report as r11 left join r11.seeds as r21 where (r21.canBeNull = 0" + subHql + ")) and r.reportXml is not null and t.templateXml is not null and r.isActive = 1 and t.isActive = 1";// WDEV-13519 if(templateName != null && templateName.length() > 0) { whereHql += " and upper(t.name) like :templateName"; markers.add("templateName"); values.add(templateName.toUpperCase() + "%"); } if(documentType != null) { whereHql += " and d.category.id = :catId"; markers.add("catId"); values.add(documentType.getID()); } if(specialty != null) { mainHql += " left join d.specialty as s left join s.instance as i"; whereHql += " and i.id = :specialtyId"; markers.add("specialtyId"); values.add(specialty.getID()); } String hql = mainHql + whereHql + " order by upper(r.reportName) asc, upper(t.name) asc";// WDEV-13519 List<?> list = factory.find(hql, markers, values); return DocumentCategoryConfigShortVoAssembler.createDocumentCategoryConfigShortVoCollectionFromDocumentCategoryConfig(list);// WDEV-13519 }