use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.
the class GPServerDAOImpl method countServers.
/**
* @param organizationName
* @param type
* @param titleOrAliasName
* @return {@link Integer}
* @throws GPDAOException
*/
@Override
public Number countServers(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<Long> criteriaQuery = builder.createQuery(Long.class);
Root<GeoPlatformServer> root = criteriaQuery.from(this.persistentClass);
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.select(builder.count(root));
criteriaQuery.where(predicates.stream().toArray(Predicate[]::new));
return this.entityManager.createQuery(criteriaQuery).getSingleResult();
} 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 findByServerUrl.
/**
* @param serverUrl
* @return {@link GeoPlatformServer}
* @throws GPDAOException
*/
@Override
public GeoPlatformServer findByServerUrl(String serverUrl) throws GPDAOException {
checkArgument(((serverUrl != null) && !(serverUrl.trim().isEmpty())), "The Parameter serverUrl must not be null or an empty string.");
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.get("serverUrl"), serverUrl));
List<GeoPlatformServer> servers = this.entityManager.createQuery(criteriaQuery).getResultList();
return ((servers != null) && !(servers.isEmpty()) ? servers.get(0) : null);
} 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 findAll.
/**
* @param type
* @return {@link List<GeoPlatformServer>}
* @throws GPDAOException
*/
@Override
public List<GeoPlatformServer> findAll(GPCapabilityType type) throws GPDAOException {
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.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 CSWServiceDelegate method getServerDetailCSW.
/**
* @see GeoPlatformCSWService#getServerDetailCSW(java.lang.Long)
*/
@Override
public GeoPlatformServer getServerDetailCSW(Long serverID) throws ResourceNotFoundFault {
GeoPlatformServer server = serverDao.find(serverID);
if (server == null) {
throw new ResourceNotFoundFault("Server not found", serverID);
}
// TODO assert
CSWEntityCorrectness.checkCSWServerLog(server);
return server;
}
use of org.geosdi.geoplatform.core.model.GeoPlatformServer in project geo-platform by geosdi.
the class CSWServiceDelegate method searchFullRecords.
/**
* TODO Factorize source code for search*Records methods.
* <p>
* Changed wrt searchSummaryRecords: 1 - ElementSetType.FULL 2 - Downcast to
* RecordType
* <p>
* TODO GMD list.
*/
@Override
public List<FullRecordDTO> searchFullRecords(int num, int start, CatalogFinderBean catalogFinder) throws Exception {
logger.trace("\n*** searchFullRecords ***\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.FULL.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<FullRecordDTO> recordListDTO = Lists.<FullRecordDTO>newArrayListWithCapacity(records.size());
for (JAXBElement<? extends AbstractRecordType> r : records) {
RecordType record = (RecordType) r.getValue();
recordListDTO.add(this.convertFullRecords(record, server));
}
return recordListDTO;
}
Aggregations