protected KeyValueEntity createKeyValueEntity(EntityParameterValue value) { KeyValueEntity keyValueEntity = new KeyValueEntity(); keyValueEntity.setValue("metaClassName", value.getMetaClassName()); keyValueEntity.setValue("entityId", value.getEntityId()); keyValueEntity.setValue("viewName", value.getViewName()); return keyValueEntity; }
@Override public void setValue(String name, Object value, boolean checkEquals) { Object oldValue = getValue(name); if ((!checkEquals) || (!InstanceUtils.propertyValueEquals(oldValue, value))) { properties.put(name, value); propertyChanged(name, oldValue, value); } }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; KeyValueEntity that = (KeyValueEntity) o; Object id = getId(); Object thatId = that.getId(); if (id != null && thatId != null) return id.equals(thatId); return Objects.equals(uuid, that.uuid); }
protected void updateEntityMetadata(KeyValueEntity entity) { entity.setMetaClass(entityMetaClass); if (idName != null) entity.setIdName(idName); } }
getNotPermittedSelectIndexes(queryParser) : Collections.emptyList(); for (Object item : resultList) { KeyValueEntity entity = new KeyValueEntity(); entity.setIdName(context.getIdName()); entities.add(entity); if (row.length > i) { if (notPermittedSelectIndexes.contains(i)) { entity.setValue(key, null); } else { entity.setValue(key, row[i]); entity.setValue(keys.get(0), null); } else { entity.setValue(keys.get(0), item);
protected void convertEnumValues(KeyValueEntity entity, List<MetaProperty> enumProperties) { try { for (MetaProperty enumProperty : enumProperties) { Object enumValue = entity.getValue(enumProperty.getName()); if (enumValue != null) { Enumeration enumeration = enumProperty.getRange().asEnumeration(); entity.setValue(enumProperty.getName(), enumeration.parse(String.valueOf(enumValue))); } } } catch (ParseException e) { throw new RuntimeException("Unable to convert enum id to enum instance for EnumClass"); } } }
@Override protected Collection<KeyValueEntity> getEntities(Map<String, Object> params) { Tag tag = (Tag) params.get("tag"); Collection<Entity> entitiesWithTag = taggingService.getEntitiesWithTag(tag); Collection<KeyValueEntity> result = new ArrayList<>(); for (Entity entity : entitiesWithTag) { KeyValueEntity keyValueEntity = metadata.create(KeyValueEntity.class); keyValueEntity.setMetaClass(entity.getMetaClass()); keyValueEntity.setValue("instanceName", entity.getInstanceName()); keyValueEntity.setValue("entity", entity); result.add(keyValueEntity); } return result; } }
@Override protected void loadData(Map<String, Object> params) { Collection<KeyValueEntity> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (KeyValueEntity entity : entities) { data.put(entity.getId(), entity); attachListener(entity); entity.setMetaClass(metaClass); } } } }
public List<KeyValueEntity> generate(PivotTableDescription description, int size) { List<KeyValueEntity> result = new ArrayList<>(size); List<String> aggregationProperties = description.getAggregationProperties(); for (int i = 0; i < size; i++) { KeyValueEntity entity = metadata.create(KeyValueEntity.class); for (PivotTableProperty property : description.getProperties()) { entity.setValue(property.getName(), generatePropertyValue(property.getName(), aggregationProperties.contains(property.getName()), size)); } result.add(entity); } return result; }
/** * Loads a list of entities. */ public List<T> list() { ValueLoadContext loadContext = createLoadContext(); return dataManager.loadValues(loadContext).stream() .map(e -> castValue(e.getValue(PROP_NAME))) .collect(Collectors.toList()); }
protected List<KeyValueEntity> getEntries(PivotTableDescription configuration) { List<BandData> childrenByName = rootBand.getChildrenByName(configuration.getBandName()); if (childrenByName == null) return Collections.emptyList(); return childrenByName.stream() .filter(band -> band.getData() != null && !band.getData().isEmpty()) .map(band -> { KeyValueEntity entity = new KeyValueEntity(); band.getData().forEach(entity::setValue); return entity; }) .collect(Collectors.toList()); } }
@Override public void addItem(KeyValueEntity item) { super.addItem(item); item.setMetaClass(metaClass); }
@Override protected void loadData(Map<String, Object> params) { Collection<KeyValueEntity> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (KeyValueEntity entity : entities) { data.put(entity.getId(), entity); attachListener(entity); entity.setMetaClass(metaClass); } } } }
/** * Loads a single instance and wraps it in Optional. */ public Optional<T> optional() { ValueLoadContext loadContext = createLoadContext(); loadContext.getQuery().setMaxResults(1); List<KeyValueEntity> list = dataManager.loadValues(loadContext); return list.isEmpty() ? Optional.empty() : Optional.ofNullable(castValue(list.get(0).getValue(PROP_NAME))); }
protected void updateEntityMetadata(KeyValueEntity entity) { entity.setMetaClass(entityMetaClass); if (idName != null) entity.setIdName(idName); }
@Override public void addItem(KeyValueEntity item) { super.addItem(item); item.setMetaClass(metaClass); }
@Override public void init(Map<String, Object> params) { BuildInfo.Content content = buildInfo.getContent(); for (Map.Entry<String, String> entry : content.getProperties().entrySet()) { KeyValueEntity entity = new KeyValueEntity(); String name = messages.getMainMessage("buildInfo." + entry.getKey()); if (name.equals("buildInfo." + entry.getKey())) name = entry.getKey(); entity.setValue("name", name); entity.setValue("value", entry.getValue()); buildInfoDs.includeItem(entity); } }
@Override protected void loadData(Map<String, Object> params) { Collection<KeyValueEntity> entities = getEntities(params); detachListener(data.values()); data.clear(); if (entities != null) { for (KeyValueEntity entity : entities) { data.put(entity.getId(), entity); attachListener(entity); entity.setMetaClass(metaClass); } } } }
/** * Loads a single instance. * * @throws IllegalStateException if nothing was loaded */ public T one() { ValueLoadContext loadContext = createLoadContext(); loadContext.getQuery().setMaxResults(1); List<KeyValueEntity> list = dataManager.loadValues(loadContext); if (!list.isEmpty()) return castValue(list.get(0).getValue(PROP_NAME)); else throw new IllegalStateException("No results"); }
@Override public void includeItem(KeyValueEntity item) { super.includeItem(item); item.setMetaClass(metaClass); }