use of org.geosdi.geoplatform.core.model.GPApplication in project geo-platform by geosdi.
the class GPAccountDAOImpl method findByAppID.
/**
* @param appID
* @return {@link GPApplication}
* @throws Exception
*/
@Override
public GPApplication findByAppID(String appID) throws GPDAOException {
checkArgument((appID != null) && !(appID.trim().isEmpty()), "" + "The Parameter appID must not be null or an empty String.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GPAccount> criteriaQuery = super.createCriteriaQuery();
Root<GPAccount> root = criteriaQuery.from(this.persistentClass);
Root<GPApplication> applicationRoot = builder.treat(root, GPApplication.class);
criteriaQuery.select(root);
criteriaQuery.where(super.criteriaBuilder().equal(applicationRoot.get("appID"), appID));
List<GPAccount> applications = this.entityManager.createQuery(criteriaQuery).getResultList();
return ((applications != null) && !(applications.isEmpty()) ? (GPApplication) applications.get(0) : null);
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPApplication in project geo-platform by geosdi.
the class GPAccountDAOImpl method countAccounts.
/**
* @param nameLike
* @return {@link Number}
* @throws GPDAOException
*/
@Override
public Number countAccounts(String nameLike) throws GPDAOException {
checkArgument(((nameLike != null) && !(nameLike.trim().isEmpty())), "The Parameter nameLike must not be null or an empty string.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<Long> criteriaQuery = builder.createQuery(Long.class);
Root<GPAccount> root = criteriaQuery.from(this.persistentClass);
Root<GPUser> userRoot = builder.treat(root, GPUser.class);
Root<GPApplication> applicationRoot = builder.treat(root, GPApplication.class);
criteriaQuery.select(builder.count(root));
criteriaQuery.where(builder.or(builder.like(builder.lower(userRoot.get("username")), nameLike.toLowerCase()), builder.like(builder.lower(applicationRoot.get("appID")), nameLike.toLowerCase())));
return entityManager.createQuery(criteriaQuery).getSingleResult();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPApplication in project geo-platform by geosdi.
the class GPAclDelegate method getApplicationPermission.
@Override
public GuiComponentsPermissionMapData getApplicationPermission(String appID) throws ResourceNotFoundFault {
// Retrieve the account
GPApplication application = accountDao.findByAppID(appID);
if (application == null) {
throw new ResourceNotFoundFault("Application not found with appID \"" + appID + "\"");
}
GuiComponentsPermissionMapData mapComponentPermission = new GuiComponentsPermissionMapData();
Map<String, Boolean> permissionMap = mapComponentPermission.getPermissionMap();
// Retrieve the Sid corresponding to the Application ID
AclSid sid = this.findSid(appID, true, null);
// Retrieve the ACEs of the Sid
List<AclEntry> entries = entryDao.findBySid(sid.getId());
logger.trace("\n*** #Entries: {} ***", entries.size());
// because there is a singe Permission)
for (AclEntry entry : entries) {
logger.trace("\n*** AclEntry:\n{}\n***", entry);
if (entry.getMask().equals(GeoPlatformPermission.ENABLE.getMask())) {
AclObjectIdentity objectIdentity = entry.getAclObject();
logger.trace("\n*** AclObjectIdentity:\n{}\n***", objectIdentity);
GuiComponent gc = guiComponentDao.find(objectIdentity.getObjectId());
logger.trace("\n*** GuiComponent:\n{}\n***", gc);
logger.debug("\n*** ComponentId: {} ***\n*** Granting: {} ***", gc.getComponentId(), entry.isGranting());
permissionMap.put(gc.getComponentId(), entry.isGranting());
}
}
return mapComponentPermission;
}
use of org.geosdi.geoplatform.core.model.GPApplication in project geo-platform by geosdi.
the class ShortAccountDTOFactoryMassiveTest method createGPApplication.
private GPApplication createGPApplication(int i) {
int f = ++i * 20;
GPApplication application = new GPApplication();
application.setId(new Long(f));
application.setOrganization(new GPOrganization("ORGANIZATION_" + "APPLICATION_TEST"));
application.setAppID("APPLICATION_TEST" + f);
return application;
}
Aggregations