package org.rabix.bindings.protocol.draft2.bean;

import java.util.List;

import org.rabix.bindings.BindingException;
import org.rabix.bindings.Bindings;
import org.rabix.bindings.BindingsFactory;
import org.rabix.bindings.model.Application;
import org.rabix.bindings.model.ApplicationPort;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.google.common.base.Function;
import com.google.common.collect.Lists;

public class Draft2EmbeddedApp extends Draft2JobApp {

  private Application application;
  private List<Draft2InputPort> inputs;
  private List<Draft2OutputPort> outputs;

  @JsonCreator
  public Draft2EmbeddedApp(String raw) {
    Bindings bindings = BindingsFactory.create(raw);
    if (bindings != null) {
      try {
        application = bindings.loadAppObject(raw);
        inputs = Lists.transform(application.getInputs(), new Function<ApplicationPort, Draft2InputPort>() {
          @Override
          public Draft2InputPort apply(ApplicationPort port) {
            return new Draft2InputPort(port.getId(), port.getDefaultValue(), port.getSchema(), null, port.getScatter(), null, port.getLinkMerge());
          }
        });
        outputs = Lists.transform(application.getInputs(), new Function<ApplicationPort, Draft2OutputPort>() {
          @Override
          public Draft2OutputPort apply(ApplicationPort port) {
            return new Draft2OutputPort(port.getId(), port.getDefaultValue(), port.getSchema(), null, port.getScatter(), null, port.getLinkMerge());
          }
        });
      } catch (BindingException e) {
        // TODO implement
      }
    }
  }
  
  @Override
  public List<Draft2InputPort> getInputs() {
    return inputs;
  }
  
  @Override
  public List<Draft2OutputPort> getOutputs() {
    return outputs;
  }
  
  @Override
  public String serialize() {
    return application.serialize();
  }
  
  @Override
  public Draft2JobAppType getType() {
    return Draft2JobAppType.EMBEDDED;
  }

}

@@ -1197,34 +1197,35 @@
 (application.get
-In
+Out
 puts(), new Func

fix Draft2EmbeddedApp