Search in sources :

Example 1 with NsStatus

use of org.talend.components.netsuite.client.NsStatus in project components by Talend.

the class NetSuiteClientServiceImpl method toNsStatus.

public static NsStatus toNsStatus(Status status) {
    if (status == null) {
        return null;
    }
    NsStatus nsStatus = new NsStatus();
    nsStatus.setSuccess(status.getIsSuccess());
    for (StatusDetail detail : status.getStatusDetail()) {
        nsStatus.getDetails().add(toNsStatusDetail(detail));
    }
    return nsStatus;
}
Also used : StatusDetail(com.netsuite.webservices.v2016_2.platform.core.StatusDetail) NsStatus(org.talend.components.netsuite.client.NsStatus)

Example 2 with NsStatus

use of org.talend.components.netsuite.client.NsStatus in project components by Talend.

the class NetSuiteClientServiceImpl method toNsStatus.

public static NsStatus toNsStatus(Status status) {
    if (status == null) {
        return null;
    }
    NsStatus nsStatus = new NsStatus();
    nsStatus.setSuccess(status.getIsSuccess());
    for (StatusDetail detail : status.getStatusDetail()) {
        nsStatus.getDetails().add(toNsStatusDetail(detail));
    }
    return nsStatus;
}
Also used : StatusDetail(com.netsuite.webservices.v2014_2.platform.core.StatusDetail) NsStatus(org.talend.components.netsuite.client.NsStatus)

Example 3 with NsStatus

use of org.talend.components.netsuite.client.NsStatus in project components by Talend.

the class TestNetSuiteClientService method toNsStatus.

public static NsStatus toNsStatus(Status status) {
    if (status == null) {
        return null;
    }
    NsStatus nsStatus = new NsStatus();
    nsStatus.setSuccess(status.getIsSuccess());
    for (StatusDetail detail : status.getStatusDetail()) {
        nsStatus.getDetails().add(toNsStatusDetail(detail));
    }
    return nsStatus;
}
Also used : StatusDetail(com.netsuite.webservices.test.platform.core.StatusDetail) NsStatus(org.talend.components.netsuite.client.NsStatus)

Example 4 with NsStatus

use of org.talend.components.netsuite.client.NsStatus in project components by Talend.

the class NetSuiteOutputWriter method createRejectRecord.

/**
 * Create record for outgoing {@code reject} flow.
 *
 * @param response write response
 * @param record indexed record which was submitted
 * @return result record
 */
private IndexedRecord createRejectRecord(NsWriteResponse<RefT> response, IndexedRecord record) {
    GenericData.Record targetRecord = new GenericData.Record(rejectSchema);
    for (Schema.Field field : schema.getFields()) {
        Schema.Field targetField = rejectSchema.getField(field.name());
        if (targetField != null) {
            Object value = record.get(field.pos());
            targetRecord.put(targetField.name(), value);
        }
    }
    String errorCode;
    String errorMessage;
    NsStatus status = response.getStatus();
    if (!status.getDetails().isEmpty()) {
        errorCode = status.getDetails().get(0).getCode();
        errorMessage = status.getDetails().get(0).getMessage();
    } else {
        errorCode = "GENERAL_ERROR";
        errorMessage = "Operation failed";
    }
    Schema.Field errorCodeField = NetSuiteDatasetRuntimeImpl.getNsFieldByName(rejectSchema, "errorCode");
    if (errorCodeField != null) {
        targetRecord.put(errorCodeField.pos(), errorCode);
    }
    Schema.Field errorMessageField = NetSuiteDatasetRuntimeImpl.getNsFieldByName(rejectSchema, "errorMessage");
    if (errorMessageField != null) {
        targetRecord.put(errorMessageField.pos(), errorMessage);
    }
    return targetRecord;
}
Also used : Schema(org.apache.avro.Schema) IndexedRecord(org.apache.avro.generic.IndexedRecord) NsStatus(org.talend.components.netsuite.client.NsStatus) GenericData(org.apache.avro.generic.GenericData)

Aggregations

NsStatus (org.talend.components.netsuite.client.NsStatus)4 StatusDetail (com.netsuite.webservices.test.platform.core.StatusDetail)1 StatusDetail (com.netsuite.webservices.v2014_2.platform.core.StatusDetail)1 StatusDetail (com.netsuite.webservices.v2016_2.platform.core.StatusDetail)1 Schema (org.apache.avro.Schema)1 GenericData (org.apache.avro.generic.GenericData)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1