use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class LayerService method loadDefaultProjectElements.
@Override
public GPClientProject loadDefaultProjectElements(HttpServletRequest httpServletRequest) throws GeoPlatformException {
Long projectId;
GPAccount account;
try {
account = this.sessionUtility.getLoggedAccount(httpServletRequest);
projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
} catch (GPSessionTimeout timeout) {
// System.out.println("Session timeout on loadDefaultProjectElements");
throw new GeoPlatformException(timeout);
}
ProjectDTO projectDTO = null;
try {
GPProject project = this.geoPlatformServiceClient.getProjectDetail(projectId);
if (account.isLoadExpandedFolders() || project.isShared()) {
projectDTO = this.geoPlatformServiceClient.getProjectWithExpandedFolders(projectId, account.getId());
} else {
projectDTO = geoPlatformServiceClient.getProjectWithRootFolders(projectId, account.getId());
}
} catch (ResourceNotFoundFault rnf) {
logger.error("Returning no elements: " + rnf);
}
try {
return this.dtoLayerConverter.convertToGPClientProject(projectDTO);
} catch (Exception ex) {
ex.printStackTrace();
throw new GeoPlatformException(ex.getMessage());
}
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class LayerService method shareProjectToUsers.
@Override
public boolean shareProjectToUsers(long idSharedProject, List<Long> accountIDsProject, HttpServletRequest httpServletRequest) throws GeoPlatformException {
boolean result;
try {
GPAccount account = this.sessionUtility.getLoggedAccount(httpServletRequest);
result = this.geoPlatformServiceClient.updateAccountsProjectSharing(new PutAccountsProjectRequest(idSharedProject, accountIDsProject));
if (result) {
MessageDTO message = new MessageDTO();
message.setCommands(Lists.newArrayList(GPMessageCommandType.OPEN_PROJECT));
message.setCommandsProperties("" + idSharedProject);
message.setCreationDate(new Date());
message.setSenderID(account.getId());
message.setSubject("Project Shared");
String sharerName;
if (account instanceof GPUser) {
GPUser user = (GPUser) account;
sharerName = user.getName();
} else {
sharerName = account.getNaturalID();
}
GPProject project = this.geoPlatformServiceClient.getProjectDetail(idSharedProject);
message.setText(sharerName + " shared with you the " + project.getName() + " project. Do you want to open it?");
message.setRecipientIDs(accountIDsProject);
this.geoPlatformServiceClient.insertMultiMessage(message);
}
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
} catch (ResourceNotFoundFault | IllegalParameterFault rnf) {
logger.error("Failed to save Shared project to Accounts for Shared Project with id: " + idSharedProject + "on SecurityService: " + rnf);
throw new GeoPlatformException(rnf);
}
return result;
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class DTOLayerConverter method convertToGProject.
/**
* @param clientProject
* @return {@link GPProject}
* @throws Exception
*/
public GPProject convertToGProject(@Nonnull(when = NEVER) GPClientProject clientProject) throws Exception {
checkArgument(clientProject != null, "The Parameter clientProject must not be null.");
GPProject project = new GPProject();
project.setName(clientProject.getName());
project.setShared(clientProject.isProjectShared());
project.setDescription(clientProject.getDescription());
project.setInternalPublic(clientProject.isInternalPublic());
project.setExternalPublic(clientProject.isExternalPublic());
project.setImagePath(clientProject.getPathImage());
return project;
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPProjectDAOImpl method findByProjectName.
/**
* @param projectName
* @return {@link GPProject}
* @throws GPDAOException
*/
@Override
public GPProject findByProjectName(String projectName) throws GPDAOException {
checkArgument((projectName != null) && !(projectName.trim().isEmpty()), "The Parameter projectName must not be null or an empty string.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GPProject> criteriaQuery = super.createCriteriaQuery();
Root<GPProject> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(root);
criteriaQuery.where(builder.equal(root.get("name"), projectName));
List<GPProject> projects = this.entityManager.createQuery(criteriaQuery).getResultList();
return ((projects != null) && !(projects.isEmpty()) ? projects.get(0) : null);
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPProjectDAOImpl method getTotalInternalPublic.
/**
* @return {@link int}
*/
@Override
public Integer getTotalInternalPublic() {
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<Long> criteriaQuery = builder.createQuery(Long.class);
Root<GPProject> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(builder.count(root));
criteriaQuery.where(builder.equal(root.get("internalPublic"), TRUE));
return this.entityManager.createQuery(criteriaQuery).getSingleResult().intValue();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
Aggregations