use of spold2.DataSet in project java-automl by googleapis.
the class ListDatasets method listDatasets.
// List the datasets
static void listDatasets(String projectId) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// A resource that represents Google Cloud Platform location.
LocationName projectLocation = LocationName.of(projectId, "us-central1");
ListDatasetsRequest request = ListDatasetsRequest.newBuilder().setParent(projectLocation.toString()).build();
// List all the datasets available in the region by applying filter.
System.out.println("List of datasets:");
for (Dataset dataset : client.listDatasets(request).iterateAll()) {
// Display the dataset information
System.out.format("%nDataset name: %s%n", dataset.getName());
// To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
// required for other methods.
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
String[] names = dataset.getName().split("/");
String retrievedDatasetId = names[names.length - 1];
System.out.format("Dataset id: %s%n", retrievedDatasetId);
System.out.format("Dataset display name: %s%n", dataset.getDisplayName());
System.out.println("Dataset create time:");
System.out.format("\tseconds: %s%n", dataset.getCreateTime().getSeconds());
System.out.format("\tnanos: %s%n", dataset.getCreateTime().getNanos());
// [END automl_video_object_tracking_list_datasets_beta]
// [END automl_tables_list_datasets]
System.out.format("Video classification dataset metadata: %s%n", dataset.getVideoClassificationDatasetMetadata());
// [END automl_video_classification_list_datasets_beta]
// [START automl_video_object_tracking_list_datasets_beta]
System.out.format("Video object tracking dataset metadata: %s%n", dataset.getVideoObjectTrackingDatasetMetadata());
// [END automl_video_object_tracking_list_datasets_beta]
// [START automl_tables_list_datasets]
System.out.format("Tables dataset metadata: %s%n", dataset.getTablesDatasetMetadata());
// [START automl_video_classification_list_datasets_beta]
// [START automl_video_object_tracking_list_datasets_beta]
}
}
}
use of spold2.DataSet in project idempiere by idempiere.
the class QueryDataLookup method getData.
/* (non-Javadoc)
* @see org.compiere.model.Lookup#getData(boolean, boolean, boolean, boolean, boolean)
*/
@Override
public ArrayList<Object> getData(boolean mandatory, boolean onlyValidated, boolean onlyActive, boolean temporary, boolean shortlist) {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
SOAPConnectionFactory cf;
try {
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
dataMap = new LinkedHashMap<Integer, KeyNamePair>();
cf = SOAPConnectionFactory.newInstance();
SOAPConnection conn = cf.createConnection();
// Create a SOAPMessage instance
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
// Create a SOAP envelope and body
SOAPPart part = message.getSOAPPart();
SOAPEnvelope env = part.getEnvelope();
SOAPBody body = env.getBody();
ModelCRUDRequestDocument crudDocument = ModelCRUDRequestDocument.Factory.newInstance();
ModelCRUDRequest crudRequest = crudDocument.addNewModelCRUDRequest();
crudRequest.setADLoginRequest(login);
ModelCRUD crud = crudRequest.addNewModelCRUD();
crud.setRecordID(0);
crud.setFilter(filter);
crud.setAction(ModelCRUD.Action.READ);
crud.setServiceType(serviceType);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element element = document.createElementNS("http://idempiere.org/ADInterface/1_0", "queryData");
Node domNode = document.importNode(crudDocument.getDomNode().getFirstChild(), true);
document.appendChild(element);
element.appendChild(domNode);
body.addDocument(document);
// Invoke the service endpoint
URL endpoint = new URL(endPoint);
SOAPMessage responseMsg = null;
try {
responseMsg = conn.call(message, endpoint);
} finally {
conn.close();
}
if (responseMsg != null && responseMsg.getSOAPBody() != null) {
if (responseMsg.getSOAPBody().hasFault()) {
throw new RuntimeException(responseMsg.getSOAPBody().getFault().getFaultString());
}
WindowTabDataDocument responseDoc = WindowTabDataDocument.Factory.parse(responseMsg.getSOAPBody().getFirstChild().getFirstChild());
WindowTabData windowTabData = responseDoc.getWindowTabData();
if (windowTabData.isSetError()) {
throw new RuntimeException(windowTabData.getError());
}
DataSet dataset = windowTabData.getDataSet();
DataRow[] dataRows = dataset.getDataRowArray();
for (DataRow dataRow : dataRows) {
DataField[] dataFields = dataRow.getFieldArray();
String key = null;
String display = null;
for (DataField dataField : dataFields) {
if (dataField.getColumn().equals(keyColumn)) {
key = dataField.getVal();
} else if (dataField.getColumn().equals(displayColumn)) {
display = dataField.getVal();
}
}
if (key != null && display != null) {
Integer id = Integer.valueOf(key);
dataMap.put(id, new KeyNamePair(id, display));
}
}
}
} catch (Exception e) {
if (e instanceof RuntimeException)
throw (RuntimeException) e;
else
throw new RuntimeException(e.getLocalizedMessage(), e);
} finally {
Thread.currentThread().setContextClassLoader(cl);
}
return new ArrayList<Object>(dataMap.values());
}
use of spold2.DataSet in project java-automl by googleapis.
the class VideoClassificationCreateDataset method createDataset.
// Create a dataset
static void createDataset(String projectId, String displayName) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// A resource that represents Google Cloud Platform location.
LocationName projectLocation = LocationName.of(projectId, "us-central1");
VideoClassificationDatasetMetadata metadata = VideoClassificationDatasetMetadata.newBuilder().build();
Dataset dataset = Dataset.newBuilder().setDisplayName(displayName).setVideoClassificationDatasetMetadata(metadata).build();
Dataset createdDataset = client.createDataset(projectLocation, dataset);
// Display the dataset information.
System.out.format("Dataset name: %s%n", createdDataset.getName());
// To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
// required for other methods.
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
String[] names = createdDataset.getName().split("/");
String datasetId = names[names.length - 1];
System.out.format("Dataset id: %s%n", datasetId);
}
}
use of spold2.DataSet in project java-automl by googleapis.
the class VideoObjectTrackingCreateDataset method createDataset.
// Create a dataset
static void createDataset(String projectId, String displayName) throws IOException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// A resource that represents Google Cloud Platform location.
LocationName projectLocation = LocationName.of(projectId, "us-central1");
VideoObjectTrackingDatasetMetadata metadata = VideoObjectTrackingDatasetMetadata.newBuilder().build();
Dataset dataset = Dataset.newBuilder().setDisplayName(displayName).setVideoObjectTrackingDatasetMetadata(metadata).build();
Dataset createdDataset = client.createDataset(projectLocation, dataset);
// Display the dataset information.
System.out.format("Dataset name: %s%n", createdDataset.getName());
// To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
// required for other methods.
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
String[] names = createdDataset.getName().split("/");
String datasetId = names[names.length - 1];
System.out.format("Dataset id: %s%n", datasetId);
}
}
use of spold2.DataSet in project java-automl by googleapis.
the class LanguageEntityExtractionCreateDataset method createDataset.
// Create a dataset
static void createDataset(String projectId, String displayName) throws IOException, ExecutionException, InterruptedException {
// the "close" method on the client to safely clean up any remaining background resources.
try (AutoMlClient client = AutoMlClient.create()) {
// A resource that represents Google Cloud Platform location.
LocationName projectLocation = LocationName.of(projectId, "us-central1");
TextExtractionDatasetMetadata metadata = TextExtractionDatasetMetadata.newBuilder().build();
Dataset dataset = Dataset.newBuilder().setDisplayName(displayName).setTextExtractionDatasetMetadata(metadata).build();
OperationFuture<Dataset, OperationMetadata> future = client.createDatasetAsync(projectLocation, dataset);
Dataset createdDataset = future.get();
// Display the dataset information.
System.out.format("Dataset name: %s\n", createdDataset.getName());
// To get the dataset id, you have to parse it out of the `name` field. As dataset Ids are
// required for other methods.
// Name Form: `projects/{project_id}/locations/{location_id}/datasets/{dataset_id}`
String[] names = createdDataset.getName().split("/");
String datasetId = names[names.length - 1];
System.out.format("Dataset id: %s\n", datasetId);
}
}
Aggregations