Instantly share code, notes, and snippets.

Embed
What would you like to do?
import java.io.File;
import java.net.URL;
import java.util.List;
import javax.xml.bind.DatatypeConverter;
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
import org.apache.commons.io.FileUtils;
import net.telestream.vantage.ws.ArrayOfItem;
import net.telestream.vantage.ws.ArrayOfstring;
import net.telestream.vantage.ws.Condition;
import net.telestream.vantage.ws.ConditionList;
import net.telestream.vantage.ws.ConditionValue;
import net.telestream.vantage.ws.Constraint;
import net.telestream.vantage.ws.Context;
import net.telestream.vantage.ws.IDomain;
import net.telestream.vantage.ws.IWorkflow;
import net.telestream.vantage.ws.ObjectFactory;
import net.telestream.vantage.ws.Procedure;
import net.telestream.vantage.ws.SdkService;
import net.telestream.vantage.ws.TypeCode;
public class Test {
public static void main(String[] args) throws Exception {
URL url = new URL("http://<vantage ip/host name>:8676/");
QName qname = new QName("http://tempuri.org/", "SdkService");
SdkService service = new SdkService(url, qname);
IDomain domain = service.getDomain();
System.out.println("Procedures: ");
List<Procedure> procedures = domain.getWorkflows().getProcedure();
procedures.forEach(p -> {
System.out.println(" - " + p.getName().getValue() + " [" + p.getIdentifier() + "]" + " " + p.getDescription().getValue() + " " + p.getLockState().value());
if (p.getConditions().isNil() == false) {
p.getConditions().getValue().getCondition().forEach(cdt -> {
System.out.println(" Condition: " + cdt.getName().getValue() + ", [instance:" + cdt.getInstance() + "] [id:" + cdt.getIdentifier() + "]");
if (cdt.getConditionValue().isNil() == false) {
ConditionValue c_value = cdt.getConditionValue().getValue();
if (c_value.getDefault().isNil() == false) {
if (c_value.getDefault().getValue().getText().isNil() == false) {
System.out.println(" default " + c_value.getDefault().getValue().getText().getValue().getString());
}
}
}
});
}
});
System.out.println();
domain.getCategories().getCategoryType().forEach(c -> {
System.out.println("Category: " + c.getName().getValue() + " [" + c.getIdentifier() + "]");
c.getWorkflows().getValue().getWorkflowType().forEach(w -> {
System.out.println(" - " + w.getName().getValue() + " [" + w.getIdentifier() + "]");
});
System.out.println();
});
// domain.getLabels()
// domain.getVariables();
// domain.getMachines()
// domain.getMediaVersions()
// service.getJob().
ObjectFactory fact = new ObjectFactory();
Context myContext = new Context();
ConditionList conditionList = new ConditionList();
JAXBElement<String> nameValue = fact.createCollectionName("Priority");
Condition priorityCondition = new Condition();
priorityCondition.setName(nameValue);
priorityCondition.setIdentifier("FF261686-8408-46b9-B6E7-D447BD5BCD82");
priorityCondition.setTypeCode(TypeCode.PRIORITY);
ConditionValue conditionValue = new ConditionValue();
ArrayOfstring myVal = new ArrayOfstring();
myVal.getString().add("5");
JAXBElement<ArrayOfstring> textValue = fact.createValueText(myVal);
conditionValue.setText(textValue);
Constraint myConstraint = new Constraint();
myConstraint.setText(textValue);
JAXBElement<Constraint> jax_Constraint = fact.createConditionValueDefault(myConstraint);
conditionValue.setDefault(jax_Constraint);
JAXBElement<ConditionValue> jax_conditionValue = fact.createConditionValue(conditionValue);
priorityCondition.setConditionValue(jax_conditionValue);
conditionList.getCondition().add(priorityCondition);
JAXBElement<ConditionList> wrappedConditions = fact.createContextConditions(conditionList);
myContext.setConditions(wrappedConditions);
service.getSubmit().submitFile("F72396C6-B121-4533-827E-DC0A844908C4", "C:\\media\\input.mpg", myContext, "SDK Sample");
IWorkflow service_workflow = service.getWorkflow();
procedures.forEach(p -> {
String identifier = p.getIdentifier();
try {
System.out.println("- " + p.getName().getValue() + " > " + service_workflow.getWorkflowState(identifier).value());
ArrayOfItem requirements = service_workflow.getWorkflowItemRequirements(identifier);
if (requirements.getItem() != null) {
requirements.getItem().forEach(item -> {
System.out.println(" requirement: " + item.getName().getValue() + " [identifier:" + item.getIdentifier() + "] [instance:" + item.getInstance() + "]");
});
}
Context context = service_workflow.getWorkflowVariableRequirements(identifier);
if (context.getConditions().isNil() == false) {
context.getConditions().getValue().getCondition().forEach(c -> {
System.out.println(" condition: " + c.getName().getValue() + " [identifier:" + c.getIdentifier() + "] [instance:" + c.getInstance() + "]");
});
}
} catch (Exception e) {
e.printStackTrace();
}
});
String compressed_workflow = service_workflow.exportToCompressed("b42bcdb5-e1f7-4068-80bb-262179e55d87");
FileUtils.writeByteArrayToFile(new File("export.bin"), DatatypeConverter.parseBase64Binary(compressed_workflow));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment