@Override public Object build(String string) { if (StringUtils.isBlank(string)) return null; EntityLoadInfo info = EntityLoadInfo.parse(string); if (info == null) throw new IllegalArgumentException("Invalid entity info: " + string); LoadContext ctx = new LoadContext(info.getMetaClass()).setId(info.getId()); if (info.getViewName() != null) ctx.setView(info.getViewName()); return ds.load(ctx); } }
protected Entity loadEntityInstance(EntityLoadInfo info) { LoadContext ctx = new LoadContext(info.getMetaClass()).setId(info.getId()); if (info.getViewName() != null) { ctx.setView(info.getViewName()); } //noinspection unchecked return dataService.load(ctx); }
protected Entity loadEntityInstance(EntityLoadInfo info) { if (info.isNewEntity()) { return metadata.create(info.getMetaClass()); } //noinspection unchecked LoadContext<Entity> ctx = new LoadContext(info.getMetaClass()).setId(info.getId()); if (info.getViewName() != null) { View view = viewRepository.findView(info.getMetaClass(), info.getViewName()); if (view != null) { ctx.setView(view); } else { log.warn("Unable to find view \"{}\" for entity \"{}\"", info.getViewName(), info.getMetaClass()); } } Entity entity; try { entity = dataService.load(ctx); } catch (Exception e) { log.warn("Unable to load item: {}", info, e); return null; } return entity; }
protected Entity loadEntityInstance(EntityLoadInfo info) { Metadata metadata = AppBeans.get(Metadata.class); if (info.isNewEntity()) { return metadata.create(info.getMetaClass()); } LoadContext ctx = new LoadContext(info.getMetaClass()).setId(info.getId()); if (info.getViewName() != null) ctx.setView(info.getViewName()); Entity entity; try { DataManager dataManager = AppBeans.get(DataManager.class); entity = dataManager.load(ctx); } catch (Exception e) { throw new BpmException("Unable to load item: " + info, e); } return entity; } }
loadCtx.setLoadDynamicAttributes(Boolean.TRUE.equals(dynamicAttributes)); loadCtx.setId(objectId); if (loadInfo.getViewName() != null) { loadCtx.setView(loadInfo.getViewName()); } else { View view = metadata.getViewRepository().getView(metaClass, View.LOCAL);
EntityManager em = persistence.getEntityManager(); View view = null; if (info.getViewName() != null) { view = metadata.getViewRepository().getView(info.getMetaClass(), info.getViewName());
public InstanceRef(EntityLoadInfo loadInfo) throws InstantiationException, IllegalAccessException { if (loadInfo == null) throw new NullPointerException("No load info passed"); this.loadInfo = loadInfo; MetaClass childMetaClass = loadInfo.getMetaClass(); if (!Strings.isNullOrEmpty(loadInfo.getViewName()) && !loadInfo.isNewEntity()) { DataService dataService = AppBeans.get(DataService.class); LoadContext<BaseGenericIdEntity<Object>> ctx = new LoadContext<>(loadInfo.getMetaClass()); ctx.setId(loadInfo.getId()).setView(loadInfo.getViewName()); instance = dataService.load(ctx); if (instance == null) { throw new RuntimeException("Entity with loadInfo " + loadInfo + " not found"); } } else { //noinspection unchecked instance = (BaseGenericIdEntity<Object>) AppBeans.get(Metadata.class).create(childMetaClass); if (!loadInfo.isNewEntity()) { for (MetaProperty metaProperty : childMetaClass.getProperties()) { if (!metaProperty.getRange().isClass()) { try { instance.setValue(metaProperty.getName(), null); } catch (Exception ignored) { } } } } } instance.setId(this.loadInfo.getId()); }