Search in sources :

Example 11 with ContentType

use of com.google.cloud.asset.v1.ContentType in project geotoolkit by Geomatys.

the class OwcXmlIO method toEntry.

private static void toEntry(String parentPath, final MapItem item, List entries) {
    final EntryType entry = ATOM_FACTORY.createEntryType();
    entries.add(ATOM_FACTORY.createFeedTypeEntry(entry));
    // store other informations
    final String name = ((parentPath != null) ? parentPath : "") + item.getIdentifier();
    final CharSequence title = item.getTitle();
    final CharSequence abstrat = item.getAbstract();
    if (name != null) {
        final IdType atom = new IdType();
        atom.setValue(name);
        entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeId(atom));
    }
    if (title != null) {
        final TextType atom = new TextType();
        atom.setType(TextTypeType.TEXT);
        atom.getContent().add(title.toString());
        entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeTitle(atom));
    }
    if (abstrat != null) {
        final TextType atom = new TextType();
        atom.setType(TextTypeType.TEXT);
        atom.getContent().add(abstrat.toString());
        entry.getAuthorOrCategoryOrContent().add(ATOM_FACTORY.createEntryTypeSummary(atom));
    }
    if (item instanceof MapLayer) {
        final MapLayer layer = (MapLayer) item;
        entry.getAuthorOrCategoryOrContent().add(GEOTK_FACTORY.createVisible(layer.isVisible()));
        entry.getAuthorOrCategoryOrContent().add(GEOTK_FACTORY.createOpacity(layer.getOpacity()));
        OfferingType offering = null;
        for (OwcExtension ext : getExtensions()) {
            if (ext.canHandle(layer)) {
                offering = ext.createOffering(layer);
                entry.getAuthorOrCategoryOrContent().add(OWC_FACTORY.createOffering(offering));
                break;
            }
        }
        // store styles
        if (offering != null) {
            if (layer.getStyle() != null) {
                final StyleSetType styleBase = toStyleSet(layer.getStyle(), true);
                offering.getOperationOrContentOrStyleSet().add(OWC_FACTORY.createOfferingTypeStyleSet(styleBase));
            }
        }
    } else if (item instanceof MapLayers) {
        final MapLayers mc = (MapLayers) item;
        final ContentType content = OWC_FACTORY.createContentType();
        content.setType(mc.getIdentifier());
        // encode children
        for (MapItem child : mc.getComponents()) {
            toEntry(name + "/", child, entries);
        }
        entry.getAuthorOrCategoryOrContent().add(OWC_FACTORY.createOfferingTypeContent(content));
    }
}
Also used : OfferingType(org.geotoolkit.owc.xml.v10.OfferingType) EntryType(org.w3._2005.atom.EntryType) ContentType(org.geotoolkit.owc.xml.v10.ContentType) StyleSetType(org.geotoolkit.owc.xml.v10.StyleSetType) MapLayer(org.apache.sis.portrayal.MapLayer) MapItem(org.apache.sis.portrayal.MapItem) IdType(org.w3._2005.atom.IdType) TextType(org.w3._2005.atom.TextType) MapLayers(org.apache.sis.portrayal.MapLayers)

Example 12 with ContentType

use of com.google.cloud.asset.v1.ContentType in project geotoolkit by Geomatys.

the class OwcXmlIO method toStyleSet.

private static StyleSetType toStyleSet(Style style, boolean def) {
    final StyleSetType styleSet = OWC_FACTORY.createStyleSetType();
    styleSet.setDefault(def);
    final ContentType content = OWC_FACTORY.createContentType();
    final StyleXmlIO io = new StyleXmlIO();
    final UserStyle jaxbStyle = io.getTransformerXMLv110().visit(style, null);
    content.getContent().add(jaxbStyle);
    styleSet.getNameOrTitleOrAbstract().add(OWC_FACTORY.createStyleSetTypeContent(content));
    return styleSet;
}
Also used : UserStyle(org.geotoolkit.sld.xml.v110.UserStyle) ContentType(org.geotoolkit.owc.xml.v10.ContentType) StyleSetType(org.geotoolkit.owc.xml.v10.StyleSetType) StyleXmlIO(org.geotoolkit.sld.xml.StyleXmlIO)

Example 13 with ContentType

use of com.google.cloud.asset.v1.ContentType in project java-asset by googleapis.

the class ExportAssetsBigqueryExample method exportBigQuery.

// Export assets to BigQuery for a project.
public static void exportBigQuery(String bigqueryDataset, String bigqueryTable, ContentType contentType, boolean isPerType) throws IOException, IllegalArgumentException, InterruptedException, ExecutionException {
    try (AssetServiceClient client = AssetServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        OutputConfig outputConfig;
        // Outputs to per-type BigQuery table.
        if (isPerType) {
            outputConfig = OutputConfig.newBuilder().setBigqueryDestination(BigQueryDestination.newBuilder().setDataset(bigqueryDataset).setTable(bigqueryTable).setForce(true).setSeparateTablesPerAssetType(true).setPartitionSpec(PartitionSpec.newBuilder().setPartitionKey(PartitionSpec.PartitionKey.READ_TIME).build()).build()).build();
        } else {
            outputConfig = OutputConfig.newBuilder().setBigqueryDestination(BigQueryDestination.newBuilder().setDataset(bigqueryDataset).setTable(bigqueryTable).setForce(true).build()).build();
        }
        ExportAssetsRequest request = ExportAssetsRequest.newBuilder().setParent(parent.toString()).setContentType(contentType).setOutputConfig(outputConfig).build();
        ExportAssetsResponse response = client.exportAssetsAsync(request).get();
        System.out.println(response);
    }
}
Also used : OutputConfig(com.google.cloud.asset.v1.OutputConfig) ExportAssetsRequest(com.google.cloud.asset.v1.ExportAssetsRequest) ProjectName(com.google.cloud.asset.v1.ProjectName) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) ExportAssetsResponse(com.google.cloud.asset.v1.ExportAssetsResponse)

Example 14 with ContentType

use of com.google.cloud.asset.v1.ContentType in project java-asset by googleapis.

the class BatchGetAssetsHistoryExample method main.

// Export assets for a project.
// @param args path where the results will be exported to.
public static void main(String... args) throws Exception {
    // Asset names, e.g.: "//storage.googleapis.com/[BUCKET_NAME]"
    String[] assetNames = args[0].split(",");
    try (AssetServiceClient client = AssetServiceClient.create()) {
        ProjectName parent = ProjectName.of(projectId);
        ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
        TimeWindow readTimeWindow = TimeWindow.newBuilder().build();
        BatchGetAssetsHistoryRequest request = BatchGetAssetsHistoryRequest.newBuilder().setParent(parent.toString()).addAllAssetNames(Arrays.asList(assetNames)).setContentType(contentType).setReadTimeWindow(readTimeWindow).build();
        BatchGetAssetsHistoryResponse response = client.batchGetAssetsHistory(request);
        System.out.println(response);
    }
}
Also used : ContentType(com.google.cloud.asset.v1.ContentType) ProjectName(com.google.cloud.asset.v1.ProjectName) AssetServiceClient(com.google.cloud.asset.v1.AssetServiceClient) BatchGetAssetsHistoryRequest(com.google.cloud.asset.v1.BatchGetAssetsHistoryRequest) BatchGetAssetsHistoryResponse(com.google.cloud.asset.v1.BatchGetAssetsHistoryResponse) TimeWindow(com.google.cloud.asset.v1.TimeWindow)

Example 15 with ContentType

use of com.google.cloud.asset.v1.ContentType in project java-asset by googleapis.

the class ListAssetsExample method listAssets.

public static void listAssets() throws IOException, IllegalArgumentException {
    // The project id of the asset parent to list.
    String projectId = "YOUR_PROJECT_ID";
    // The asset types to list. E.g.,
    // ["storage.googleapis.com/Bucket", "bigquery.googleapis.com/Table"].
    // See full list of supported asset types at
    // https://cloud.google.com/asset-inventory/docs/supported-asset-types.
    String[] assetTypes = { "YOUR_ASSET_TYPES_TO_LIST" };
    // The asset content type to list. E.g., ContentType.CONTENT_TYPE_UNSPECIFIED.
    // See full list of content types at
    // https://cloud.google.com/asset-inventory/docs/reference/rpc/google.cloud.asset.v1#contenttype
    ContentType contentType = ContentType.CONTENT_TYPE_UNSPECIFIED;
    listAssets(projectId, assetTypes, contentType);
}
Also used : ContentType(com.google.cloud.asset.v1.ContentType)

Aggregations

AssetServiceClient (com.google.cloud.asset.v1.AssetServiceClient)5 ContentType (com.google.cloud.asset.v1.ContentType)4 ProjectName (com.google.cloud.asset.v1.ProjectName)4 IOException (java.io.IOException)4 ContentType (org.geotoolkit.owc.xml.v10.ContentType)4 ArrayList (java.util.ArrayList)3 Document (org.dom4j.Document)3 DocumentException (org.dom4j.DocumentException)3 Element (org.dom4j.Element)3 SAXReader (org.dom4j.io.SAXReader)3 StyleSetType (org.geotoolkit.owc.xml.v10.StyleSetType)3 ContentType (org.ttzero.excel.entity.e7.ContentType)3 ExportAssetsRequest (com.google.cloud.asset.v1.ExportAssetsRequest)2 ExportAssetsResponse (com.google.cloud.asset.v1.ExportAssetsResponse)2 OutputConfig (com.google.cloud.asset.v1.OutputConfig)2 Path (java.nio.file.Path)2 List (java.util.List)2 JAXBElement (javax.xml.bind.JAXBElement)2 MapItem (org.apache.sis.portrayal.MapItem)2 MapLayer (org.apache.sis.portrayal.MapLayer)2