So I’ve got the Data Import add-on installed, and I tried it out on a simple case, an entity with just a description and a two-value Enum, and the import went just fine…except the Enum attribute was left null.
The Enum is a simple one built in Studio:
public enum OrthoticOrProsthetic implements EnumClass<String> {
Orthotic("O"),
Prosthetic("P");
private String id;
OrthoticOrProsthetic(String value) {
this.id = value;
}
public String getId() {
return id;
}
@Nullable
public static OrthoticOrProsthetic fromId(String id) {
for (OrthoticOrProsthetic at : OrthoticOrProsthetic.values()) {
if (at.getId().equals(id)) {
return at;
}
}
return null;
}
}
All of the values in the column in the CSV file are either O or P so I believe it should have worked.
Where should I start looking to find out why it failed?
11:48:20.766 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: O for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.803 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: O for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.816 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: O for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.829 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: O for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.841 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: O for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.852 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: O for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.865 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: O for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.878 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: P for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.890 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: P for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.904 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: P for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.916 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: P for Enum: OrthoticOrProsthetic. Will be ignored
11:48:20.929 INFO d.d.c.d.binding.DatatypeFactory - Enum value could not be found: P for Enum: OrthoticOrProsthetic. Will be ignored
Setting that as a script causes an exception for each row:
12:29:10.245 ERROR d.d.c.d.b.CustomScriptAttributeBinder - Error while executing custom binding script: class groovy.lang.MissingPropertyException
groovy.lang.MissingPropertyException: No such property: OrthoticOrProsthetic for class: Script1
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:65) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:51) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:309) ~[groovy-2.5.8.jar:2.5.8]
at Script1.run(Script1.groovy:3) ~[na:na]
at com.haulmont.cuba.core.sys.AbstractScripting.evaluateGroovy(AbstractScripting.java:206) ~[cuba-global-7.2.1.jar:7.2.1]
at com.haulmont.cuba.core.sys.AbstractScripting.evaluateGroovy(AbstractScripting.java:234) ~[cuba-global-7.2.1.jar:7.2.1]
at com.haulmont.cuba.core.global.Scripting$evaluateGroovy.call(Unknown Source) ~[na:na]
at de.diedavids.cuba.dataimport.binding.CustomScriptAttributeBinder.getValue(CustomScriptAttributeBinder.groovy:43) ~[dataimport-core-0.12.0.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:190) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:58) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:176) ~[groovy-2.5.8.jar:2.5.8]
at de.diedavids.cuba.dataimport.binding.CustomScriptAttributeBinder.tryToExecuteCustomScriptAndSetValue(CustomScriptAttributeBinder.groovy:23) ~[dataimport-core-0.12.0.jar:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
at org.codehaus.groovy.runtime.callsite.PlainObjectMetaMethodSite.doInvoke(PlainObjectMetaMethodSite.java:43) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:190) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:58) ~[groovy-2.5.8.jar:2.5.8]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:184) ~[groovy-2.5.8.jar:2.5.8]
at de.diedavids.cuba.dataimport.binding.CustomScriptAttributeBinder.bindAttribute(CustomScriptAttributeBinder.groovy:18) ~[dataimport-core-0.12.0.jar:na]
(The trace goes on longer.)
Does the script need an import or similar for the Enum?