JSONArray buildJavaScriptProvisionableSites() { JSONArray sites = new JSONArray(); if (getCanProvisionAllSites()) { sites.put( new MapBuilder<String, String>() .put("identifier", JSON_ALL_SCOPE_IDENTIFIER) .put("name", allName(ScopeType.SITE)) .toMap()); } for (Site site : getProvisionableSites()) { sites.put( new MapBuilder<String, String>() .put("name", site.getName()) .put("identifier", site.getAssignedIdentifier()) .toMap()); } return sites; }
@SuppressWarnings({"unchecked"}) public List<Site> getByAssignedIdentifiers(List<String> assignedIdentifiers) { if (assignedIdentifiers.isEmpty()) { return Collections.emptyList(); } List fromDatabase = getHibernateTemplate() .findByCriteria( criteria().add(MoreRestrictions.in("assignedIdentifier", assignedIdentifiers))); List<Site> inOrder = new ArrayList<Site>(); for (String assignedIdentifier : assignedIdentifiers) { for (Iterator<Site> foundIt = fromDatabase.iterator(); foundIt.hasNext(); ) { Site found = foundIt.next(); if (found.getAssignedIdentifier().equals(assignedIdentifier)) { inOrder.add(found); foundIt.remove(); break; } } } return inOrder; }
public void deleteAll(List<Site> t) { for (Site site : t) site.stopManaging(); getHibernateTemplate().deleteAll(t); }
/** * Deletes a site * * @param site the site to delete */ public void delete(final Site site) { site.stopManaging(); // it's bogus that hibernate apparently can't do this itself getHibernateTemplate().delete(site); }