@Override public void setValue(Object value, ValueFields valueFields) { EntityManagerSession entityManagerSession = Context.getCommandContext().getSession(EntityManagerSession.class); if (entityManagerSession == null) { throw new ActivitiException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured"); } else { // Before we set the value we must flush all pending changes from // the entitymanager // If we don't do this, in some cases the primary key will not yet // be set in the object // which will cause exceptions down the road. entityManagerSession.flush(); } if (value instanceof List<?> && ((List<?>) value).size() > 0) { List<?> list = (List<?>) value; List<String> ids = new ArrayList<String>(); String type = mappings.getJPAClassString(list.get(0)); for (Object entry : list) { ids.add(mappings.getJPAIdString(entry)); } // Store type in text field and the ID's as a serialized array valueFields.setBytes(serializeIds(ids)); valueFields.setTextValue(type); } else if (value == null) { valueFields.setBytes(null); valueFields.setTextValue(null); } else { throw new ActivitiIllegalArgumentException("Value is not a list of JPA entities: " + value); } }
public void setValue(Object value, ValueFields valueFields) { EntityManagerSession entityManagerSession = Context.getCommandContext().getSession(EntityManagerSession.class); if (entityManagerSession == null) { throw new ActivitiException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured"); } else { // Before we set the value we must flush all pending changes from // the entitymanager // If we don't do this, in some cases the primary key will not yet // be set in the object // which will cause exceptions down the road. entityManagerSession.flush(); } if (value != null) { String className = mappings.getJPAClassString(value); String idString = mappings.getJPAIdString(value); valueFields.setTextValue(className); valueFields.setTextValue2(idString); } else { valueFields.setTextValue(null); valueFields.setTextValue2(null); } }
@Override public void setValue(Object value, ValueFields valueFields) { EntityManagerSession entityManagerSession = Context.getCommandContext().getSession(EntityManagerSession.class); if (entityManagerSession == null) { throw new ActivitiException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured"); } else { // Before we set the value we must flush all pending changes from // the entitymanager // If we don't do this, in some cases the primary key will not yet // be set in the object // which will cause exceptions down the road. entityManagerSession.flush(); } if (value instanceof List<?> && ((List<?>) value).size() > 0) { List<?> list = (List<?>) value; List<String> ids = new ArrayList<String>(); String type = mappings.getJPAClassString(list.get(0)); for (Object entry : list) { ids.add(mappings.getJPAIdString(entry)); } // Store type in text field and the ID's as a serialized array valueFields.setBytes(serializeIds(ids)); valueFields.setTextValue(type); } else if (value == null) { valueFields.setBytes(null); valueFields.setTextValue(null); } else { throw new ActivitiIllegalArgumentException("Value is not a list of JPA entities: " + value); } }
public void setValue(Object value, ValueFields valueFields) { EntityManagerSession entityManagerSession = Context .getCommandContext() .getSession(EntityManagerSession.class); if (entityManagerSession == null) { throw new ActivitiException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured"); } else { // Before we set the value we must flush all pending changes from the entitymanager // If we don't do this, in some cases the primary key will not yet be set in the object // which will cause exceptions down the road. entityManagerSession.flush(); } if(value != null) { String className = mappings.getJPAClassString(value); String idString = mappings.getJPAIdString(value); valueFields.setTextValue(className); valueFields.setTextValue2(idString); } else { valueFields.setTextValue(null); valueFields.setTextValue2(null); } }
public void setValue(Object value, ValueFields valueFields) { EntityManagerSession entityManagerSession = Context.getCommandContext().getSession(EntityManagerSession.class); if (entityManagerSession == null) { throw new ActivitiException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured"); } else { // Before we set the value we must flush all pending changes from // the entitymanager // If we don't do this, in some cases the primary key will not yet // be set in the object // which will cause exceptions down the road. entityManagerSession.flush(); } if (value != null) { String className = mappings.getJPAClassString(value); String idString = mappings.getJPAIdString(value); valueFields.setTextValue(className); valueFields.setTextValue2(idString); } else { valueFields.setTextValue(null); valueFields.setTextValue2(null); } }
@Override public void setValue(Object value, ValueFields valueFields) { EntityManagerSession entityManagerSession = Context .getCommandContext() .getSession(EntityManagerSession.class); if (entityManagerSession == null) { throw new ActivitiException("Cannot set JPA variable: " + EntityManagerSession.class + " not configured"); } else { // Before we set the value we must flush all pending changes from the entitymanager // If we don't do this, in some cases the primary key will not yet be set in the object // which will cause exceptions down the road. entityManagerSession.flush(); } if (value != null) { String className = mappings.getJPAClassString(value); String idString = mappings.getJPAIdString(value); valueFields.setTextValue(className); valueFields.setTextValue2(idString); } else { valueFields.setTextValue(null); valueFields.setTextValue2(null); } }