emfjson / emfjson-jackson

JSON Binding for Eclipse Modeling Framework
https://emfjson.github.io
Other
80 stars 23 forks source link

error on type ENUM convert json to EMF #40

Closed elvisqi closed 10 years ago

elvisqi commented 10 years ago

java.lang.IllegalArgumentException: The value 'RULEASCOLUMN' is not a valid enumerator of 'DecisionTableOrientation' at DMN.impl.DMNFactoryImpl.createDecisionTableOrientationFromString(DMNFactoryImpl.java:405) at DMN.impl.DMNFactoryImpl.createFromString(DMNFactoryImpl.java:101) at org.eclipse.emf.ecore.util.EcoreUtil.createFromString(EcoreUtil.java:3352) at org.eclipselabs.emfjson.map.EAtttributeDeserializer.deSerializeValue(EAtttributeDeserializer.java:86) at org.eclipselabs.emfjson.map.EAtttributeDeserializer.deSerialize(EAtttributeDeserializer.java:69) at org.eclipselabs.emfjson.map.Deserializer.from(Deserializer.java:71) at org.eclipselabs.emfjson.map.EReferenceDeserializer.createContainedObject(EReferenceDeserializer.java:107) at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerializeContainment(EReferenceDeserializer.java:86) at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerialize(EReferenceDeserializer.java:59) at org.eclipselabs.emfjson.map.Deserializer.from(Deserializer.java:72) at org.eclipselabs.emfjson.map.EReferenceDeserializer.createContainedObject(EReferenceDeserializer.java:107) at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerializeContainment(EReferenceDeserializer.java:74) at org.eclipselabs.emfjson.map.EReferenceDeserializer.deSerialize(EReferenceDeserializer.java:59) at org.eclipselabs.emfjson.map.Deserializer.from(Deserializer.java:72) at org.eclipselabs.emfjson.map.EObjectMapper.from(EObjectMapper.java:105) at org.eclipselabs.emfjson.map.EObjectMapper.from(EObjectMapper.java:96) at org.eclipselabs.emfjson.map.EObjectMapper.from(EObjectMapper.java:71) at org.eclipselabs.emfjson.resource.JsResourceImpl.doLoad(JsResourceImpl.java:49) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518) at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297) at com.founder.fix.test.FigureBuilderDMNTest.readWriteFigureEnum(FigureBuilderDMNTest.java:127) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

elvisqi commented 10 years ago
/**
 */
package DMN;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.eclipse.emf.common.util.Enumerator;

/**
 * <!-- begin-user-doc -->
 * A representation of the literals of the enumeration '<em><b>Decision Table Orientation</b></em>',
 * and utility methods for working with them.
 * <!-- end-user-doc -->
 * @see DMN.DMNPackage#getDecisionTableOrientation()
 * @model
 * @generated
 */
public enum DecisionTableOrientation implements Enumerator {
    /**
     * The '<em><b>Ruleas Row</b></em>' literal object.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #RULEAS_ROW_VALUE
     * @generated
     * @ordered
     */
    RULEAS_ROW(0, "RuleasRow", "RuleasRow"),

    /**
     * The '<em><b>Ruleas Column</b></em>' literal object.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #RULEAS_COLUMN_VALUE
     * @generated
     * @ordered
     */
    RULEAS_COLUMN(1, "RuleasColumn", "RuleasColumn"),

    /**
     * The '<em><b>Cross Table</b></em>' literal object.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #CROSS_TABLE_VALUE
     * @generated
     * @ordered
     */
    CROSS_TABLE(2, "CrossTable", "CrossTable");

    /**
     * The '<em><b>Ruleas Row</b></em>' literal value.
     * <!-- begin-user-doc -->
     * <p>
     * If the meaning of '<em><b>Ruleas Row</b></em>' literal object isn't clear,
     * there really should be more of a description here...
     * </p>
     * <!-- end-user-doc -->
     * @see #RULEAS_ROW
     * @model name="RuleasRow"
     * @generated
     * @ordered
     */
    public static final int RULEAS_ROW_VALUE = 0;

    /**
     * The '<em><b>Ruleas Column</b></em>' literal value.
     * <!-- begin-user-doc -->
     * <p>
     * If the meaning of '<em><b>Ruleas Column</b></em>' literal object isn't clear,
     * there really should be more of a description here...
     * </p>
     * <!-- end-user-doc -->
     * @see #RULEAS_COLUMN
     * @model name="RuleasColumn"
     * @generated
     * @ordered
     */
    public static final int RULEAS_COLUMN_VALUE = 1;

    /**
     * The '<em><b>Cross Table</b></em>' literal value.
     * <!-- begin-user-doc -->
     * <p>
     * If the meaning of '<em><b>Cross Table</b></em>' literal object isn't clear,
     * there really should be more of a description here...
     * </p>
     * <!-- end-user-doc -->
     * @see #CROSS_TABLE
     * @model name="CrossTable"
     * @generated
     * @ordered
     */
    public static final int CROSS_TABLE_VALUE = 2;

    /**
     * An array of all the '<em><b>Decision Table Orientation</b></em>' enumerators.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    private static final DecisionTableOrientation[] VALUES_ARRAY =
        new DecisionTableOrientation[] {
            RULEAS_ROW,
            RULEAS_COLUMN,
            CROSS_TABLE,
        };

    /**
     * A public read-only list of all the '<em><b>Decision Table Orientation</b></em>' enumerators.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static final List<DecisionTableOrientation> VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));

    /**
     * Returns the '<em><b>Decision Table Orientation</b></em>' literal with the specified literal value.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static DecisionTableOrientation get(String literal) {
        for (int i = 0; i < VALUES_ARRAY.length; ++i) {
            DecisionTableOrientation result = VALUES_ARRAY[i];
            if (result.toString().equals(literal)) {
                return result;
            }
        }
        return null;
    }

    /**
     * Returns the '<em><b>Decision Table Orientation</b></em>' literal with the specified name.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static DecisionTableOrientation getByName(String name) {
        for (int i = 0; i < VALUES_ARRAY.length; ++i) {
            DecisionTableOrientation result = VALUES_ARRAY[i];
            if (result.getName().equals(name)) {
                return result;
            }
        }
        return null;
    }

    /**
     * Returns the '<em><b>Decision Table Orientation</b></em>' literal with the specified integer value.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static DecisionTableOrientation get(int value) {
        switch (value) {
            case RULEAS_ROW_VALUE: return RULEAS_ROW;
            case RULEAS_COLUMN_VALUE: return RULEAS_COLUMN;
            case CROSS_TABLE_VALUE: return CROSS_TABLE;
        }
        return null;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    private final int value;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    private final String name;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    private final String literal;

    /**
     * Only this class can construct instances.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    private DecisionTableOrientation(int value, String name, String literal) {
        this.value = value;
        this.name = name;
        this.literal = literal;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getValue() {
      return value;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getName() {
      return name;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public String getLiteral() {
      return literal;
    }

    /**
     * Returns the literal value of the enumerator, which is its string representation.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        return literal;
    }

} //DecisionTableOrientation
elvisqi commented 10 years ago

the xmi is on http://www.omg.org/spec/DMN/20130901/DMN.xmi

elvisqi commented 10 years ago
{
  "eClass" : "http://www.omg.org/spec/DMN/20130901#//Definitions",
  "id" : "df_figureEnum",
  "name" : "57",
  "description" : "DRD for Application Routing decision point",
  "drgElement" : [ {
    "eClass" : "http://www.omg.org/spec/DMN/20130901#//Decision",
    "id" : "d_routing",
    "name" : "路由",
    "description" : "routing",
    "question" : "",
    "allowedAnswers" : "",
    "definitions" : {
      "$ref" : "/",
      "eClass" : "http://www.omg.org/spec/DMN/20130901#//Definitions"
    },
    "decisionLogic" : {
      "eClass" : "http://www.omg.org/spec/DMN/20130901#//DecisionTable",
      "id" : "dt_d_post_bureau_risk_category",
      "name" : "办事处风险分类",
      "hitPolicy" : "UNIQUE",
      "aggregation" : "SUM",
      "preferedOrientation" : "RuleasColumn",
      "isComplete" : true,
      "decision" : {
        "$ref" : "//@drgElement.0",
        "eClass" : "http://www.omg.org/spec/DMN/20130901#//Decision"
      }
    }
  } ]
}
elvisqi commented 10 years ago
<?xml version="1.0" encoding="utf-8"?>
<DMN:Definitions xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:DMN="http://www.omg.org/spec/DMN/20130901" id="df_figureEnum" name="57" description="DRD for Application Routing decision point">
  <drgElement xsi:type="DMN:Decision" id="d_routing" name="路由" description="routing" question="" allowedAnswers="">
    <decisionLogic xsi:type="DMN:DecisionTable" id="dt_d_post_bureau_risk_category" name="办事处风险分类" aggregation="SUM" preferedOrientation="RuleasColumn" isComplete="true"/>
  </drgElement>
</DMN:Definitions>

the xml load is fine

ghillairet commented 10 years ago

Should be fixed, can you try?

elvisqi commented 10 years ago

wow, it's fine! passed all test case! thank you ~