use of com.google.cloud.automl.v1beta1.Dataset in project idempiere by idempiere.
the class GetListLookup 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<Object, NamePair>();
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();
ModelGetListRequestDocument getListDocument = ModelGetListRequestDocument.Factory.newInstance();
ModelGetListRequest getListRequest = getListDocument.addNewModelGetListRequest();
getListRequest.setADLoginRequest(login);
ModelGetList getList = getListRequest.addNewModelGetList();
getList.setFilter(filter);
getList.setServiceType(serviceType);
body.addDocument((Document) getListDocument.getDomNode());
// 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) {
dataMap.put(key, new ValueNamePair(key, 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 com.google.cloud.automl.v1beta1.Dataset in project olca-modules by GreenDelta.
the class DataSetIterator method next.
@Override
public DataSet next() {
DataSet current = next;
moveNext();
return current;
}
use of com.google.cloud.automl.v1beta1.Dataset in project java-aiplatform by googleapis.
the class ImportDataImageClassificationSampleTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException, ExecutionException, TimeoutException {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
// create a temp dataset for importing data
DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/image_1.0.0.yaml";
LocationName locationName = LocationName.of(PROJECT, LOCATION);
Dataset dataset = Dataset.newBuilder().setDisplayName("test_dataset_display_name").setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
Dataset datasetResponse = datasetFuture.get(120, TimeUnit.SECONDS);
String[] datasetValues = datasetResponse.getName().split("/");
datasetId = datasetValues[datasetValues.length - 1];
}
}
use of com.google.cloud.automl.v1beta1.Dataset in project java-aiplatform by googleapis.
the class ImportDataVideoActionRecognitionSampleTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException, ExecutionException, TimeoutException {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
// create a temp dataset for importing data
DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/video_1.0.0.yaml";
LocationName locationName = LocationName.of(PROJECT, LOCATION);
Dataset dataset = Dataset.newBuilder().setDisplayName("test_dataset_display_name").setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
Dataset datasetResponse = datasetFuture.get(300, TimeUnit.SECONDS);
String[] datasetValues = datasetResponse.getName().split("/");
datasetId = datasetValues[datasetValues.length - 1];
}
}
use of com.google.cloud.automl.v1beta1.Dataset in project java-aiplatform by googleapis.
the class ImportDataVideoClassificationSampleTest method setUp.
@Before
public void setUp() throws IOException, InterruptedException, ExecutionException, TimeoutException {
bout = new ByteArrayOutputStream();
out = new PrintStream(bout);
originalPrintStream = System.out;
System.setOut(out);
// create a temp dataset for importing data
DatasetServiceSettings datasetServiceSettings = DatasetServiceSettings.newBuilder().setEndpoint("us-central1-aiplatform.googleapis.com:443").build();
try (DatasetServiceClient datasetServiceClient = DatasetServiceClient.create(datasetServiceSettings)) {
String metadataSchemaUri = "gs://google-cloud-aiplatform/schema/dataset/metadata/video_1.0.0.yaml";
LocationName locationName = LocationName.of(PROJECT, LOCATION);
Dataset dataset = Dataset.newBuilder().setDisplayName("test_dataset_display_name").setMetadataSchemaUri(metadataSchemaUri).build();
OperationFuture<Dataset, CreateDatasetOperationMetadata> datasetFuture = datasetServiceClient.createDatasetAsync(locationName, dataset);
Dataset datasetResponse = datasetFuture.get(300, TimeUnit.SECONDS);
String[] datasetValues = datasetResponse.getName().split("/");
datasetId = datasetValues[datasetValues.length - 1];
}
}
Aggregations