Hi, i’m trying to import a JSON from an “Embedded Entity” with the EntityImportExportService service but always returns a zero length array.
Its exported with this code (its ok):
getItem().setVinculos(entityImportExportService.exportEntitiesToJSON(eventoVinculosDs.getItems()));
Saved JSON:
[ { "_entityName": "caerp$EventoVinculo", "id": "1", "requerido": false, "nombre": "Bien", "disponible": true }, { "_entityName": "caerp$EventoVinculo", "id": "2", "requerido": false, "nombre": "Cliente", "disponible": true }, { "_entityName": "caerp$EventoVinculo", "id": "3", "requerido": false, "nombre": "Comprobante", "disponible": false }, { "_entityName": "caerp$EventoVinculo", "id": "4", "requerido": false, "nombre": "Contacto", "disponible": false }, { "_entityName": "caerp$EventoVinculo", "id": "5", "requerido": false, "nombre": "Evento", "disponible": false }, { "_entityName": "caerp$EventoVinculo", "id": "6", "requerido": false, "nombre": "Proeveedor", "disponible": false }]
And this is the code for import (error):
EntityImportView viewVinculos = new EntityImportView(EventoVinculo.class);
viewVinculos.addLocalProperties();
Collection<Entity> vinculos = entityImportExportService.importEntitiesFromJSON(item.getVinculos(), viewVinculos);
If i set the view to NULL, i get a null pointer exception.
Now, this is my Entity:
package com.company.caerp.entity;
import com.haulmont.chile.core.annotations.MetaClass;
import com.haulmont.chile.core.annotations.MetaProperty;
import javax.validation.constraints.NotNull;
import com.haulmont.cuba.core.entity.BaseIntegerIdEntity;
import com.haulmont.chile.core.annotations.NamePattern;
@NamePattern("%s|nombre")
@MetaClass(name = "caerp$EventoVinculo")
public class EventoVinculo extends BaseIntegerIdEntity {
private static final long serialVersionUID = 6804086645020152334L;
@NotNull
@MetaProperty(mandatory = true)
protected String nombre;
@NotNull
@MetaProperty(mandatory = true)
protected Boolean disponible = false;
@MetaProperty
protected Boolean requerido;
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getNombre() {
return nombre;
}
public void setDisponible(Boolean disponible) {
this.disponible = disponible;
}
public Boolean getDisponible() {
return disponible;
}
public void setRequerido(Boolean requerido) {
this.requerido = requerido;
}
public Boolean getRequerido() {
return requerido;
}
}
regards!!