Search in sources :

Example 1 with FullRecordDTO

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

Example 2 with FullRecordDTO

use of org.geosdi.geoplatform.responce.FullRecordDTO in project geo-platform by geosdi.

the class GPCatalogFinderService method searchFullRecords.

@Override
public PagingLoadResult<FullRecord> searchFullRecords(PagingLoadConfig config, CatalogFinderBean catalogFinder, HttpServletRequest httpServletRequest) throws Exception {
    logger.debug("\n--------------------------\n{}\n--------------------------\n", catalogFinder);
    int recordsCount;
    ArrayList<FullRecord> searchRecords;
    try {
        recordsCount = geoPlatformCSWClient.getRecordsCount(catalogFinder);
        if (recordsCount == 0) {
            logger.info("\n*** No Full Record found ***");
            searchRecords = new ArrayList<FullRecord>(0);
        } else {
            List<FullRecordDTO> recordList = geoPlatformCSWClient.searchFullRecords(config.getLimit(), config.getOffset() + 1, catalogFinder);
            searchRecords = new ArrayList<FullRecord>(recordList.size());
            for (FullRecordDTO recordDTO : recordList) {
                searchRecords.add(this.convertFullRecordDTO(recordDTO));
            }
        }
    } catch (IllegalParameterFault ex) {
        logger.error("\n*** IllegalParameterFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    } catch (ResourceNotFoundFault ex) {
        logger.error("\n*** ResourceNotFoundFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    } catch (ServerInternalFault ex) {
        logger.error("\n*** ServerInternalFault ***\n{}", ex.getMessage());
        throw new GeoPlatformException(ex.getMessage());
    }
    return new BasePagingLoadResult<FullRecord>(searchRecords, config.getOffset(), recordsCount);
}
Also used : IllegalParameterFault(org.geosdi.geoplatform.exception.IllegalParameterFault) FullRecord(org.geosdi.geoplatform.gui.client.model.FullRecord) ResourceNotFoundFault(org.geosdi.geoplatform.exception.ResourceNotFoundFault) FullRecordDTO(org.geosdi.geoplatform.responce.FullRecordDTO) ServerInternalFault(org.geosdi.geoplatform.exception.ServerInternalFault) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) BasePagingLoadResult(com.extjs.gxt.ui.client.data.BasePagingLoadResult)

Example 3 with FullRecordDTO

use of org.geosdi.geoplatform.responce.FullRecordDTO in project geo-platform by geosdi.

the class CSWServiceDelegate method convertFullRecords.

private FullRecordDTO convertFullRecords(RecordType record, GeoPlatformServer server) {
    FullRecordDTO dto = new FullRecordDTO();
    dto.setIdCatalog(server.getId());
    dto.setCatalogURL(server.getServerUrl());
    this.gpDublinCoreAnalyzer.analyzeRecord(record, dto);
    return dto;
}
Also used : FullRecordDTO(org.geosdi.geoplatform.responce.FullRecordDTO)

Example 4 with FullRecordDTO

use of org.geosdi.geoplatform.responce.FullRecordDTO in project geo-platform by geosdi.

the class CSWCatalogRecordTest method testGetRecordsOurResultFullGetCapabilities.

@Test
public void testGetRecordsOurResultFullGetCapabilities() throws Exception {
    String title = "Protezione Civile Web Map Service";
    TextInfo textInfo = catalogFinder.getTextInfo();
    textInfo.setText(title);
    textInfo.setSearchTitle(true);
    textInfo.setSearchAbstract(false);
    textInfo.setSearchSubjects(false);
    List<FullRecordDTO> records = cswService.searchFullRecords(10, 1, catalogFinder);
    this.traceCollection(records);
    assertEquals(1, records.size());
    FullRecordDTO record = records.get(0);
    assertEquals(title, record.getTitle());
    assertEquals("d759996e6da0dee66a515e9f236da6c575cb1d83", record.getIdentifier());
    assertEquals("service", record.getType());
    assertTrue(record.getAbstractText().contains("WMS Server del Dipartimento della Protezione Civile Nazionale"));
    assertNotNull(record.getSubjects());
    assertEquals("WFS", record.getSubjects().get(0));
    assertEquals("WMS", record.getSubjects().get(1));
    assertEquals("GEOSERVER", record.getSubjects().get(2));
    assertNotNull(record.getUriMap());
    assertEquals(1, record.getUriMap().size());
}
Also used : TextInfo(org.geosdi.geoplatform.gui.responce.TextInfo) FullRecordDTO(org.geosdi.geoplatform.responce.FullRecordDTO) Test(org.junit.Test)

Aggregations

FullRecordDTO (org.geosdi.geoplatform.responce.FullRecordDTO)4 ServerInternalFault (org.geosdi.geoplatform.exception.ServerInternalFault)2 BasePagingLoadResult (com.extjs.gxt.ui.client.data.BasePagingLoadResult)1 JAXBElement (javax.xml.bind.JAXBElement)1 GeoPlatformServer (org.geosdi.geoplatform.core.model.GeoPlatformServer)1 IllegalParameterFault (org.geosdi.geoplatform.exception.IllegalParameterFault)1 ResourceNotFoundFault (org.geosdi.geoplatform.exception.ResourceNotFoundFault)1 FullRecord (org.geosdi.geoplatform.gui.client.model.FullRecord)1 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)1 TextInfo (org.geosdi.geoplatform.gui.responce.TextInfo)1 Test (org.junit.Test)1