Search in sources :

Example 21 with GeoPlatformServer

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);
    }
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 22 with GeoPlatformServer

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);
    }
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) GPDAOException(org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)

Example 23 with GeoPlatformServer

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);
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ServerCSWDTO(org.geosdi.geoplatform.responce.ServerCSWDTO) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault)

Example 24 with GeoPlatformServer

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);
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization)

Example 25 with GeoPlatformServer

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;
}
Also used : GeoPlatformServer(org.geosdi.geoplatform.core.model.GeoPlatformServer) ArrayList(java.util.ArrayList) SummaryRecordDTO(org.geosdi.geoplatform.responce.SummaryRecordDTO) ServerInternalFault(org.geosdi.geoplatform.exception.ServerInternalFault) JAXBElement(javax.xml.bind.JAXBElement)

Aggregations

GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)40 Test (org.junit.Test)15 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)9 ServerDTO (org.geosdi.geoplatform.response.ServerDTO)8 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)6 GPDAOException (org.geosdi.geoplatform.persistence.dao.exception.GPDAOException)6 ServerCSWDTO (org.geosdi.geoplatform.responce.ServerCSWDTO)3 Ignore (org.junit.Ignore)3 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 JAXBElement (javax.xml.bind.JAXBElement)2 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)2 ServerInternalFault (org.geosdi.geoplatform.exception.ServerInternalFault)2 PaginatedSearchRequest (org.geosdi.geoplatform.request.PaginatedSearchRequest)2 WSSaveServerRequest (org.geosdi.geoplatform.request.server.WSSaveServerRequest)2 RasterLayerDTO (org.geosdi.geoplatform.response.RasterLayerDTO)2 IOException (java.io.IOException)1 URL (java.net.URL)1 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1