use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPProjectDAOImpl method getTotalExternalPublic.
/**
* @return {@link int}
*/
@Override
public Integer getTotalExternalPublic() {
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("externalPublic"), TRUE));
return this.entityManager.createQuery(criteriaQuery).getSingleResult().intValue();
} 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 findInternalPublic.
/**
* @param size
* @param page
* @return {@link List<GPProject>}
* @throws GPDAOException
*/
@Override
public List<GPProject> findInternalPublic(int size, int page) throws GPDAOException {
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("internalPublic"), TRUE));
TypedQuery<GPProject> typedQuery = this.entityManager.createQuery(criteriaQuery);
Integer firstResult = (page == 0) ? 0 : ((page * size));
typedQuery.setFirstResult(firstResult);
typedQuery.setMaxResults(size);
return typedQuery.getResultList();
} 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 GPTrackingServiceImpl method sendSharedProjectNotification.
/**
* @see GPTrackingService#sendSharedProjectNotification(java.lang.Long,
* org.geosdi.geoplatform.services.XMPPSubjectServerEnum, java.lang.String,
* org.geosdi.geoplatform.responce.collection.XmppAttributesMap)
*/
@Override
public void sendSharedProjectNotification(Long projectID, XMPPSubjectEnum subject, String text, XmppAttributesMap attributesMap) throws ResourceNotFoundFault {
GPProject project = projectDao.find(projectID);
if (project == null) {
throw new ResourceNotFoundFault("Project not found", projectID);
}
// TODO assert
EntityCorrectness.checkProjectLog(project);
if (!project.isShared()) {
// TODO assert
throw new EntityCorrectnessException("The Project must be shared.");
}
List<GPAccountProject> accounts = accountProjectDao.findNotOwnersByProjectID(projectID);
// TODO assert
EntityCorrectness.checkAccountProjectListLog(accounts);
Roster roster = this.connection.getRoster();
Message message = this.createUnknowMessage(subject, text, attributesMap);
for (GPAccountProject accountProject : accounts) {
GPAccount account = accountProject.getAccount();
// TODO assert
EntityCorrectness.checkAccountLog(account);
// If user have this project as default
if (accountProject.isDefaultProject()) {
// Username for User
String naturalID = account.getNaturalID();
String recipient = this.createXmppUri(naturalID);
logger.trace("\n\n*** Recipient XMPP uri: {} ***", recipient);
// If user is online send the message
Presence presence = roster.getPresence(recipient);
if (presence.isAvailable()) {
logger.info("\n*** Send Message to online user \"{}\" ***", naturalID);
message.setTo(recipient);
connection.sendPacket(message);
}
}
}
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class GPFolderDelegate method insertFolder.
// <editor-fold defaultstate="collapsed" desc="Folder">
// =========================================================================
// === Folder
// =========================================================================
@Override
public Long insertFolder(InsertFolderRequest insertFolderRequest) throws ResourceNotFoundFault, IllegalParameterFault {
Long projectID = insertFolderRequest.getProjectID();
GPFolder folder = insertFolderRequest.getFolder();
if (projectID == null) {
throw new IllegalParameterFault("The projectID must not be null.");
}
if (folder == null) {
throw new IllegalParameterFault("The GPFolder passed in Request must " + "not be null.");
}
GPProject project = projectDao.find(projectID);
if (project == null) {
throw new ResourceNotFoundFault("Project not found", projectID);
}
// TODO assert
EntityCorrectness.checkProjectLog(project);
folder.setProject(project);
// TODO assert
EntityCorrectness.checkFolder(folder);
folderDao.persist(folder);
return folder.getId();
}
use of org.geosdi.geoplatform.core.model.GPProject in project geo-platform by geosdi.
the class ProjectDTO method convertToGPProject.
/**
* Convert an instance of ProjectDTO to {@link GPProject}: will convert all
* fields unless version and shared fields.
*/
public static GPProject convertToGPProject(@Nonnull(when = NEVER) ProjectDTO projectDTO) {
checkArgument(projectDTO != null, "The Parameter ProjectDTO must not be null");
GPProject project = new GPProject();
project.setId(projectDTO.getId());
project.setName(projectDTO.getName());
if (projectDTO.getNumberOfElements() != null) {
project.setNumberOfElements(projectDTO.getNumberOfElements());
}
if (projectDTO.getDescription() != null) {
project.setDescription(projectDTO.getDescription());
}
if (projectDTO.getImagePath() != null) {
project.setImagePath(projectDTO.getImagePath());
}
project.setInternalPublic(projectDTO.isInternalPublic());
project.setExternalPublic(projectDTO.isExternalPublic());
project.setShared(projectDTO.isShared());
return project;
}
Aggregations