use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.
the class GPServerDAOImpl method findAll.
/**
* @param idOrganization
* @param type
* @return {@link List<GeoPlatformServer>}
* @throws GPDAOException
*/
@Override
public List<GeoPlatformServer> findAll(Long idOrganization, GPCapabilityType type) throws GPDAOException {
checkArgument(idOrganization != null, "The Parameter idOrganization must not be null.");
checkArgument(type != null, "The Parameter type must not ne null.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GeoPlatformServer> criteriaQuery = super.createCriteriaQuery();
Root<GeoPlatformServer> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(root);
criteriaQuery.where(builder.equal(root.join("organization").get("id"), idOrganization), builder.equal(root.get("serverType"), type));
return this.entityManager.createQuery(criteriaQuery).getResultList();
} catch (Exception ex) {
ex.printStackTrace();
throw new GPDAOException(ex);
}
}
use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.
the class GPServerDAOImpl method searchPagebleServers.
/**
* @param page
* @param size
* @param organizationName
* @param titleOrAliasName
* @return {@link List<GeoPlatformServer>}
* @throws GPDAOException
*/
@Override
public List<GeoPlatformServer> searchPagebleServers(Integer page, Integer size, String organizationName, GPCapabilityType type, String titleOrAliasName) throws GPDAOException {
checkArgument((organizationName != null) && !(organizationName.trim().isEmpty()), "The Parameter organizationName must not ne null or an empty string.");
checkArgument(type != null, "The Parameter type must not ne null.");
try {
CriteriaBuilder builder = super.criteriaBuilder();
CriteriaQuery<GeoPlatformServer> criteriaQuery = super.createCriteriaQuery();
Root<GeoPlatformServer> root = criteriaQuery.from(this.persistentClass);
criteriaQuery.select(root);
List<Predicate> predicates = Lists.newArrayList();
if ((titleOrAliasName != null) && !(titleOrAliasName.trim().isEmpty())) {
predicates.add(builder.or(builder.like(builder.lower(root.get("title")), titleOrAliasName.toLowerCase()), builder.like(builder.lower(root.get("aliasName")), titleOrAliasName.toLowerCase())));
}
Join<GeoPlatformServer, GPOrganization> join = root.join("organization");
predicates.add(builder.equal(join.get("name"), organizationName));
predicates.add(builder.equal(root.get("serverType"), type));
criteriaQuery.where(predicates.stream().toArray(Predicate[]::new)).orderBy(builder.asc(root.get("aliasName")));
TypedQuery<GeoPlatformServer> 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.GeoPlatformServer in project geo-platform by geosdi.
the class CSWServiceDelegate method getShortServerCSW.
/**
* @see GeoPlatformCSWService#getShortServerCSW(java.lang.String)
*/
@Override
public ServerCSWDTO getShortServerCSW(String serverUrl) throws ResourceNotFoundFault {
GeoPlatformServer server = serverDao.findByServerUrl(serverUrl);
if (server == null) {
throw new ResourceNotFoundFault("Server not found " + serverUrl);
}
// TODO assert
CSWEntityCorrectness.checkCSWServerLog(server);
return new ServerCSWDTO(server);
}
use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.
the class CSWServiceDelegate method getAllCSWServers.
/**
* @see {@link GeoPlatformCSWService#getAllCSWServers(String)} ()}
*/
@Override
public List<ServerCSWDTO> getAllCSWServers(String organizationName) throws ResourceNotFoundFault {
GPOrganization organization = organizationDao.findByName(organizationName);
if (organization == null) {
throw new ResourceNotFoundFault("Organization with name " + organizationName + "was not found.");
}
List<GeoPlatformServer> found = serverDao.findAll(organization.getId(), GPCapabilityType.CSW);
return convertServerList(found);
}
use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.
the class CSWServiceDelegate method searchSummaryRecords.
/**
* TODO Factorize source code for search*Records methods.
* <p>
* TODO GMD list.
*/
@Override
public List<SummaryRecordDTO> searchSummaryRecords(int num, int start, CatalogFinderBean catalogFinder) throws Exception {
logger.trace("\n*** searchSummaryRecords ***\n{}", catalogFinder);
GeoPlatformServer server = this.getCSWServerByID(catalogFinder.getServerID());
CatalogGetRecordsRequest<GetRecordsResponseType> request = this.createGetRecordsRequest(server.getServerUrl());
request.setTypeName(TypeName.RECORD_V202);
request.setOutputSchema(OutputSchema.CSW_V202);
request.setElementSetName(ElementSetType.SUMMARY.value());
request.setResultType(ResultType.RESULTS.value());
request.setConstraintLanguage(ConstraintLanguage.FILTER);
request.setConstraintLanguageVersion(ConstraintLanguageVersion.V110);
request.setCatalogFinder(catalogFinder);
// Pagination search
request.setMaxRecords(BigInteger.valueOf(num));
request.setStartPosition(BigInteger.valueOf(start));
logger.debug("\n*** Num: {} *** Start: {} ***", request.getMaxRecords(), request.getStartPosition());
GetRecordsResponseType response = this.createGetRecordsResponse(request);
logger.debug("\n*** Records matched: {} *** Records returned: {} *** Record next: {} ***", response.getSearchResults().getNumberOfRecordsMatched(), response.getSearchResults().getNumberOfRecordsReturned(), response.getSearchResults().getNextRecord());
if (response.getSearchResults().getNumberOfRecordsReturned().intValue() != response.getSearchResults().getAbstractRecord().size()) {
throw new ServerInternalFault("CSW Catalog Server Error: incorrect number of records, expected " + response.getSearchResults().getNumberOfRecordsReturned() + " but was " + response.getSearchResults().getAbstractRecord().size());
}
List<JAXBElement<? extends AbstractRecordType>> records = response.getSearchResults().getAbstractRecord();
logger.trace("\n*** Record list size: {} ***", records.size());
List<SummaryRecordDTO> recordListDTO = new ArrayList<SummaryRecordDTO>(records.size());
for (JAXBElement<? extends AbstractRecordType> record : records) {
SummaryRecordType summary = (SummaryRecordType) record.getValue();
recordListDTO.add(this.convertSummaryRecords(summary, server));
}
return recordListDTO;
}
Aggregations