/** * Move a location site */ @SuppressWarnings("unchecked") public void moveLocSite(ims.core.vo.LocSiteVo locSiteToMove, OrgShortVo currentParent, OrgShortVo destParent) throws StaleObjectException { DomainFactory factory = getDomainFactory(); LocSite doLocSite = LocSiteVoAssembler.extractLocSite(factory, locSiteToMove); Organisation doOrgCurrentParent = OrgShortVoAssembler.extractOrganisation(factory, currentParent); Organisation doOrgDestParent = OrgShortVoAssembler.extractOrganisation(factory, destParent); //strange hibernate(v3) error was being generated here and session refresh problems so hence the factory.refresh() calls doLocSite.setParentOrganisation(doOrgDestParent); doOrgCurrentParent.getLocationSites().remove(doLocSite); factory.refresh(doOrgCurrentParent); doOrgDestParent.getLocationSites().add(doLocSite); factory.save(doLocSite); factory.refresh(doOrgCurrentParent); //WDEV-10574 REMOTE_LOC_CACHE.clear(); }
public OrgShortVo saveOrganisationShort(OrgShortVo organisation) throws StaleObjectException, UniqueKeyViolationException { /*String result = "";*/ DomainFactory factory = getDomainFactory(); Organisation doOrg = OrgShortVoAssembler.extractOrganisation(factory, organisation); /*String serviceActivityUnique = isTaxonomyUnique(organisation.getCodeMappings()); result += serviceActivityUnique; if(result.length() > 0) throw new UniqueKeyViolationException(result); */ try { doOrg.setUpperNames(); factory.save(doOrg); } catch (UnqViolationUncheckedException e) { throw new UniqueKeyViolationException("An Organisation with this details already exists within the system, please change", e); } return OrgShortVoAssembler.create(doOrg); }
public OrgShortVoCollection listOrganisationsShort(OrgShortVo filter) { List orgs = listDomOrganisation(filter); OrgShortVoCollection voCollOrgShorts = OrgShortVoAssembler.createOrgShortVoCollectionFromOrganisation(orgs); voCollOrgShorts.sort(); return voCollOrgShorts; }
public OrgShortVoCollection listOrganisation() { DomainFactory factory = getDomainFactory(); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); StringBuffer condStr = new StringBuffer(); String andStr = " and "; List orgs = null; String hql = " from Organisation o where o.type.id != " + OrganisationType.SUPPLIER.getID(); condStr.append(andStr + " (o.type != :GP or o.type.id is null)"); markers.add("GP"); values.add(getDomLookup(OrganisationType.GPP)); condStr.append(andStr + " o.isActive = :isActive"); markers.add("isActive"); values.add(Boolean.TRUE); condStr.append(andStr + " o.parentOrganisation is null"); hql += condStr.toString(); orgs = factory.find(hql, markers, values); return OrgShortVoAssembler.createOrgShortVoCollectionFromOrganisation(orgs).sort(); }
public OrgShortVo getOrganisationShort(String name) { if(name == null) throw new CodingRuntimeException("The Organisation Name must not be null. "); if(name != null) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" from Organisation as o1_1 where "); String andStr = " "; ArrayList<String> markers = new ArrayList<String>(); ArrayList<Serializable> values = new ArrayList<Serializable>(); hql.append(andStr + " o1_1.name = :NAME"); markers.add("NAME"); values.add(name); andStr = " and "; hql.append(andStr + " o1_1.isActive = :ACTIVE"); markers.add("ACTIVE"); values.add(Boolean.TRUE); List list = factory.find(hql.toString(), markers,values); if(list != null && list.size() > 0) { OrgShortVoCollection voColl = OrgShortVoAssembler.createOrgShortVoCollectionFromOrganisation(list); if(voColl != null && voColl.size() > 0) return voColl.get(0); } } return null; }
public OrgShortVoCollection getOrganisationShortCollection(String name) { if(name == null) throw new CodingRuntimeException("The Organisation Name must not be null. "); if(name != null) { DomainFactory factory = getDomainFactory(); StringBuffer hql = new StringBuffer(" from Organisation as o1_1 where "); String andStr = " "; ArrayList<String> markers = new ArrayList<String>(); ArrayList<Serializable> values = new ArrayList<Serializable>(); hql.append(andStr + " o1_1.name = :NAME"); markers.add("NAME"); values.add(name); andStr = " and "; hql.append(andStr + " o1_1.isActive = :ACTIVE"); markers.add("ACTIVE"); values.add(Boolean.TRUE); List list = factory.find(hql.toString(), markers,values); if(list != null && list.size() > 0) { OrgShortVoCollection voColl = OrgShortVoAssembler.createOrgShortVoCollectionFromOrganisation(list); return voColl; } } return null; }
public OrgShortVoCollection list(Boolean activeOnly) { return OrgShortVoAssembler.createOrgShortVoCollectionFromOrganisation( getDomainFactory().find("select o1_1 from Organisation as o1_1 where (o1_1.type = -82) ")); }
public OrgShortVoCollection listOrganisationForType(OrganisationType type, OrgShortVo voOrgShort, Boolean bActive) { if (type == null) throw new DomainRuntimeException("No type provided for listOrganisationForType"); DomainFactory factory = getDomainFactory(); ArrayList markers = new ArrayList(); ArrayList values = new ArrayList(); String hql = " from Organisation o "; StringBuffer condStr = new StringBuffer(); String andStr = " "; List orgs = null; condStr.append(andStr + " o.type.id = " + type.getID()); andStr = " and "; if (voOrgShort != null && voOrgShort.getNameIsNotNull()) { String name = voOrgShort.getName(); if (name.endsWith("%")) name = name.substring(0,name.length()-1); condStr.append(andStr + " (upper(o.name) like :orgName "); markers.add("orgName"); values.add("%"+ name.toUpperCase() + "%"); condStr.append(")"); andStr = " and "; } if (bActive != null) { condStr.append(andStr + "o.isActive = :active"); markers.add("active"); values.add(bActive); } hql += " where "; hql += condStr.toString(); orgs = factory.find(hql, markers, values, 1000); OrgShortVoCollection voCollOrgs = OrgShortVoAssembler.createOrgShortVoCollectionFromOrganisation(orgs); voCollOrgs.sort(); return voCollOrgs; }