Search in sources :

Example 76 with Dataset

use of com.google.cloud.aiplatform.v1.Dataset in project geonetwork-microservices by geonetwork.

the class DcatTest method testJsonToDcat.

@Test
public void testJsonToDcat() throws IOException {
    String identifier = "1567-765175-6561756";
    Dataset dcatDataset = Dataset.builder().title(List.of("Rivers on earth")).description(List.of("Water drop ...")).identifier(List.of(identifier)).subject(List.of(Subject.builder().skosConcept(SkosConcept.builder().about("https://registry.org/hydrology").prefLabel("Hydrology").build()).build(), Subject.builder().skosConcept(SkosConcept.builder().prefLabel("Earth observation").build()).build())).landingPage(List.of(DcatDocument.builder().foafDocument(FoafDocument.builder().about("https://data/file.zip").title("Download dataset").description("CC0").format("Shapefile").build()).build())).qualifiedRelation(List.of(DcatRelationship.builder().relation(DcatRelation.builder().relation("http://...TODO").build()).build())).spatialResolutionInMeters(List.of(new BigDecimal(25000))).temporalResolution(List.of(Duration.ofDays(15))).accessRights(List.of(DcatAccessRights.builder().rightsStatement(RightsStatement.builder().label("public access limited according to Article 13(1)(b) of the INSPIRE Directive").about("https://registry.inspire/...").build()).build())).accrualPeriodicity(new RdfResource(null, ACCRUAL_PERIODICITY_URI_PREFIX + ACCRUAL_PERIODICITY_TO_ISO.get("daily"), null)).conformsTo(new RdfResource(null, "http://iso19115-3.schema.org", null)).created(new Date()).isReferencedBy(List.of(new RdfResource(null, "https://isReferencedBy", null))).relation(List.of(new RdfResource(null, "https://relation", null))).language(List.of(new RdfResource(null, "http://publications.europa.eu/resource/authority/language/FRE", null))).type(List.of(Subject.builder().skosConcept(SkosConcept.builder().prefLabel("dataset").build()).build())).page(List.of(DcatDocument.builder().foafDocument(FoafDocument.builder().about("https://apps.titellus.net/ogcapi/collections/main/items/" + identifier).build()).build())).versionInfo("1.0").qualifiedAttribution(List.of(DcatQualifiedAttribution.builder().attribution(ProvAttribution.builder().agent(new RdfResource(null, "http://agent", null)).hadRole(new RdfResource(null, "http://role/creator", null)).build()).build())).comment(List.of("Comments ...")).distribution(List.of(DcatDistributionContainer.builder().distribution(DcatDistribution.builder().accessUrl("https://sdi.eea.europa.eu/webdav/continental/europe/natural_areas/birds_directive/eea_v_3035_10_mio_art12-2008-2012_i_2008-2012_v01_r01/Art12-2008-2012_SHP").build()).build())).license(DcatLicenseDocumentContainer.builder().license(DcatLicenseDocument.builder().type(Subject.builder().skosConcept(SkosConcept.builder().prefLabel("CC0").build()).build()).build()).build()).build();
    // POJO to XML
    JAXBContext context = null;
    String dcatXml = null;
    try {
        StringWriter sw = new StringWriter();
        context = JAXBContext.newInstance(SkosConcept.class, Dataset.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
        marshaller.marshal(dcatDataset, sw);
        dcatXml = sw.toString();
    } catch (JAXBException e) {
        e.printStackTrace();
    }
    org.eclipse.rdf4j.model.Model model = Rio.parse(new ByteArrayInputStream(dcatXml.getBytes()), "", RDFFormat.RDFXML);
    // Rio.write(model, System.out, RDFFormat.RDFXML);
    Rio.write(model, System.out, RDFFormat.TURTLE);
// Rio.write(model, System.out, RDFFormat.JSONLD);
}
Also used : Marshaller(javax.xml.bind.Marshaller) Dataset(org.fao.geonet.index.model.dcat2.Dataset) JAXBException(javax.xml.bind.JAXBException) JAXBContext(javax.xml.bind.JAXBContext) BigDecimal(java.math.BigDecimal) Date(java.util.Date) StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) RdfResource(org.fao.geonet.index.model.dcat2.RdfResource) SkosConcept(org.fao.geonet.index.model.dcat2.SkosConcept) Test(org.junit.Test)

Aggregations

DatasetServiceClient (com.google.cloud.aiplatform.v1.DatasetServiceClient)15 DatasetServiceSettings (com.google.cloud.aiplatform.v1.DatasetServiceSettings)15 LocationName (com.google.cloud.aiplatform.v1.LocationName)14 IOException (java.io.IOException)14 GcsSource (com.google.cloud.aiplatform.v1.GcsSource)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 PrintStream (java.io.PrintStream)10 ArrayList (java.util.ArrayList)10 Before (org.junit.Before)10 DatasetName (com.google.cloud.aiplatform.v1.DatasetName)9 ImportDataConfig (com.google.cloud.aiplatform.v1.ImportDataConfig)8 ImportDataOperationMetadata (com.google.cloud.aiplatform.v1.ImportDataOperationMetadata)8 ImportDataResponse (com.google.cloud.aiplatform.v1.ImportDataResponse)8 AutoMlClient (com.google.cloud.automl.v1.AutoMlClient)8 Dataset (com.google.cloud.automl.v1.Dataset)8 LocationName (com.google.cloud.automl.v1.LocationName)7 Dataset (com.google.cloud.datalabeling.v1beta1.Dataset)7 CreateDatasetOperationMetadata (com.google.cloud.aiplatform.v1.CreateDatasetOperationMetadata)6 Dataset (com.google.cloud.aiplatform.v1.Dataset)6 OperationMetadata (com.google.cloud.automl.v1.OperationMetadata)6