use of org.geosdi.geoplatform.core.model.GPFolder in project geo-platform by geosdi.
the class LayerService method saveFolder.
@Override
public Long saveFolder(Long idParentFolder, String folderName, int position, int numberOfDescendants, boolean isChecked, HttpServletRequest httpServletRequest) throws GeoPlatformException {
try {
this.sessionUtility.getLoggedAccount(httpServletRequest);
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
GPFolder gpFolder = null;
try {
gpFolder = geoPlatformServiceClient.getFolderDetail(idParentFolder);
} catch (Exception e) {
logger.error("LayerService", "Ubable to load Folder with ID : " + idParentFolder);
throw new GeoPlatformException("The Folder with ID : " + idParentFolder + " was deleted.");
}
GPFolder folder = new GPFolder();
folder.setName(folderName);
folder.setPosition(position);
folder.setShared(false);
folder.setParent(gpFolder);
folder.setNumberOfDescendants(numberOfDescendants);
folder.setChecked(isChecked);
Long projectId;
// folder.setProject(project);
Long savedFolderId = null;
try {
projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
savedFolderId = this.geoPlatformServiceClient.insertFolder(new InsertFolderRequest(projectId, folder));
} catch (IllegalParameterFault ilg) {
logger.error("Error on LayerService: " + ilg);
throw new GeoPlatformException("Parameter incorrect on saveFolde");
} catch (ResourceNotFoundFault rnff) {
logger.error("Error on LayerService: " + rnff);
throw new GeoPlatformException(rnff);
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
return savedFolderId;
}
use of org.geosdi.geoplatform.core.model.GPFolder in project geo-platform by geosdi.
the class LayerService method saveAddedFolderAndTreeModifications.
@Override
public Long saveAddedFolderAndTreeModifications(MementoSaveAddedFolder memento, HttpServletRequest httpServletRequest) throws GeoPlatformException {
try {
this.sessionUtility.getLoggedAccount(httpServletRequest);
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
}
GPWebServiceMapData map = this.dtoMementoConverter.convertDescendantMap(memento.getWsDescendantMap());
Long idSavedFolder;
try {
Long projectId = this.sessionUtility.getDefaultProject(httpServletRequest);
GPFolder gpFolder = this.dtoLayerConverter.convertMementoFolder(memento.getAddedFolder());
idSavedFolder = this.geoPlatformServiceClient.saveAddedFolderAndTreeModifications(new WSAddFolderAndTreeModificationsRequest(projectId, memento.getAddedFolder().getIdParent(), gpFolder, map));
} catch (ResourceNotFoundFault ex) {
this.logger.error("Failed to save folder on LayerService: " + ex);
throw new GeoPlatformException(ex);
} catch (IllegalParameterFault ilg) {
logger.error("Error on LayerService: " + ilg);
throw new GeoPlatformException("Parameter incorrect on saveAddedFolderAndTreeModifications");
} catch (GPSessionTimeout timeout) {
throw new GeoPlatformException(timeout);
} catch (Exception ex) {
throw new GeoPlatformException(ex.getMessage());
}
return idSavedFolder;
}
use of org.geosdi.geoplatform.core.model.GPFolder in project geo-platform by geosdi.
the class DTOLayerConverter method convertMementoFolder.
/**
* @param memento
* @return {@link GPFolder}
* @throws Exception
*/
public GPFolder convertMementoFolder(@Nonnull(when = NEVER) MementoFolder memento) throws Exception {
checkArgument(memento != null, "The Parameter memento must not be null.");
GPFolder gpFolder = new GPFolder();
gpFolder.setId(memento.getIdBaseElement());
gpFolder.setName(memento.getFolderName());
gpFolder.setNumberOfDescendants(memento.getNumberOfDescendants());
gpFolder.setPosition(memento.getzIndex());
/*
* TODO: Once implemented shared function you must set this property
* gpFolder.setShared(true);
*/
return gpFolder;
}
use of org.geosdi.geoplatform.core.model.GPFolder in project geo-platform by geosdi.
the class GPFolderDAOImpl method persistCheckStatusFolder.
/**
* @param folderID
* @param checked
* @return {@link Boolean}
* @throws GPDAOException
*/
@Override
public Boolean persistCheckStatusFolder(Long folderID, boolean checked) throws GPDAOException {
checkArgument(folderID != null, "The Parameter folderID must not be null.");
GPFolder folder = super.find(folderID);
if (folder == null) {
logger.debug("\n*** The Folder with ID \"{}\" is NOT exist into DB ***", folderID);
return FALSE;
}
logger.trace("\n*** Folder RETRIEVED:\n{}\n*** MOD checked to {} ***", folder, checked);
// Merge iff the check status is different
if (folder.isChecked() != checked) {
folder.setChecked(checked);
GPFolder folderUpdated = super.update(folder);
if (folderUpdated.isChecked() != checked) {
return FALSE;
}
}
return TRUE;
}
use of org.geosdi.geoplatform.core.model.GPFolder in project geo-platform by geosdi.
the class GPFolderDAOImpl method find.
/**
* @param ids
* @return {@link }
* @throws GPDAOException
*/
@Override
public List<GPFolder> find(Long... ids) throws GPDAOException {
checkArgument(ids != null, "The Parameter ids must not be null.");
try {
List<Long> values = Stream.of(ids).filter(Objects::nonNull).collect(toList());
checkArgument((values != null) && !(values.isEmpty()), "The Parameter ids must contains element.");
CriteriaQuery<GPFolder> criteriaQuery = super.createCriteriaQuery();
Root<GPFolder> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(root);
criteriaQuery.where(root.get("id").in(values));
return this.entityManager.createQuery(criteriaQuery).getResultList();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
Aggregations