@Override public Map<BeanId, Bean> list(String schemaName, Collection<String> ids) throws AbortRuntimeException { List<BeanId> beanIds = new ArrayList<>(); for (String id : ids) { beanIds.add(BeanId.create(id, schemaName)); } List<Bean> beans = findEager(beanIds); return uniqueIndex(beans); }
private void mergeJpaBeans(Collection<Bean> beans) { Map<BeanId, Bean> mapBeans = uniqueIndex(beans); List<Bean> stored = findEager(mapBeans.keySet()); for (Bean bean : beans) { if (!stored.contains(bean)) { throw CFG304_BEAN_DOESNT_EXIST(bean.getId()); } } mergeProperties(mapBeans, stored); mergeReferences(mapBeans, stored); }
@Override public Map<BeanId, Bean> list(String schemaName) { try { if (!begin()) { return new HashMap<>(); } List<Bean> beans = findEager(schemaName); commit(); return uniqueIndex(beans); } catch (AbortRuntimeException e) { rollback(); throw e; } catch (Throwable e) { rollback(); throw new RuntimeException(e); } }
private void initReferences(Collection<Bean> beans) { Map<BeanId, Bean> indexed = BeanUtils.uniqueIndex(beans); for (Bean bean : beans) { for (String name : bean.getReferenceNames()) { List<BeanId> ids = bean.getReference(name); if (ids == null) { continue; } for (BeanId id : ids) { Bean ref = indexed.get(id); if (ref == null) { // TODO: investigate if eager is really needed Optional<Bean> optionalRef = beanManager.getEager(id); if (optionalRef.isPresent()) { core.setSchema(optionalRef.get(), schemaManager.getSchemas()); ref = optionalRef.get(); } } id.setBean(ref); } } } }
private void setJpaBean(Collection<Bean> beans) { Map<BeanId, Bean> mapBeans = uniqueIndex(beans); List<Bean> stored = findEager(mapBeans.keySet()); for (Bean bean : beans) { if (!stored.contains(bean)) { // ignore } } for (Bean bean : beans) { deleteProperties(bean.getId()); deleteReferences(bean.getId()); createJpaProperties(bean); } createJpaRefs(beans); }
private void initReferences(Collection<Bean> beans) { Map<BeanId, Bean> indexed = BeanUtils.uniqueIndex(beans); for (Bean bean : beans) { for (String name : bean.getReferenceNames()) { List<BeanId> ids = bean.getReference(name); for (BeanId id : ids) { Bean ref = indexed.get(id); if (ref == null) { // TODO: investigate if eager is really needed ref = beanManager.getEager(id); setSchema(ref, schemaManager.getSchemas()); } id.setBean(ref); } } } }
return uniqueIndex(beansToValidate); } catch (AbortRuntimeException e) { rollback();
Map<BeanId, Bean> userProvided = BeanUtils.uniqueIndex(beans); for (Bean bean : beans) { for (String name : bean.getReferenceNames()) {
/** * Used for setting or creating a multiple beans. * * We must consider that the operation may include beans that have * references betewen eachother. User provided beans are * prioritized and the storage is secondary for looking up references. */ private void initalizeReferences(Collection<Bean> beans) { Map<BeanId, Bean> userProvided = BeanUtils.uniqueIndex(beans); for (Bean bean : beans) { for (String name : bean.getReferenceNames()) { List<BeanId> values = bean.getReference(name); if (values == null) { continue; } for (BeanId beanId : values) { // the does not exist in storage, but may exist in the // set of beans provided by the user. Bean ref = userProvided.get(beanId); if (ref == null) { ref = beanManager.getEager(beanId); } beanId.setBean(ref); setSchema(beanId.getBean(), schemaManager.getSchemas()); } } } }