com.haulmont.cuba.core.entity.Entity.setValue()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中com.haulmont.cuba.core.entity.Entity.setValue()方法的一些代码示例,展示了Entity.setValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.setValue()方法的具体详情如下:
包路径:com.haulmont.cuba.core.entity.Entity
类名称:Entity
方法名:setValue

Entity.setValue介绍

暂无

代码示例

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected void setParentField(Entity item, String parentProperty, Entity parent) {
  if (parentProperty != null && parent != null && item != null)
    item.setValue(parentProperty, parent);
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

protected void setField(Entity bean, String field, Object value)
    throws IllegalAccessException, InvocationTargetException, IntrospectionException {
  bean.setValue(field, value);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
public void setAllDay(boolean isAllDay) {
  entity.setValue(provider.getIsAllDayProperty(), isAllDay);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
public void setStart(Date start) {
  entity.setValue(provider.getStartDateProperty(), start);
}

代码示例来源:origin: com.haulmont.reports/reports-gui

@Override
  public void accept(String caption) {
    datasource.getItem().setValue(fieldName, caption);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
public void setStyleName(String styleName) {
  entity.setValue(provider.getStyleNameProperty(), styleName);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
public void setEnd(Date end) {
  entity.setValue(provider.getEndDateProperty(), end);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
public void setCaption(String caption) {
  entity.setValue(provider.getCaptionProperty(), caption);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected void setInitialValuesToItem(Entity item) {
  Map<String, Object> values = getInitialValues();
  if (values != null) {
    for (Map.Entry<String, Object> entry : values.entrySet()) {
      item.setValue(entry.getKey(), entry.getValue());
    }
  }
  if (initialValuesSupplier != null) {
    Map<String, Object> supplierValues = initialValuesSupplier.get();
    if (supplierValues != null) {
      for (Map.Entry<String, Object> entry : supplierValues.entrySet()) {
        item.setValue(entry.getKey(), entry.getValue());
      }
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

@Override
public void setDescription(String description) {
  entity.setValue(provider.getDescriptionProperty(), description);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected void updateMasterCollection(MetaProperty metaProperty, @Nullable Collection<V> newCollection) {
  if (newCollection == null) {
    getMaster().getItem().setValue(metaProperty.getName(), null);
  } else {
    Collection<V> masterCollection;
    if (List.class.isAssignableFrom(metaProperty.getJavaType())) {
      masterCollection = new ArrayList(newCollection);
    } else {
      masterCollection = new LinkedHashSet(newCollection);
    }
    getMaster().getItem().setValue(metaProperty.getName(), masterCollection);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected void setFullName(String displayedName) {
  if (datasource != null) {
    datasource.getItem().setValue("name", displayedName);
  } else if (window != null) {
    Field field = (Field) window.getComponentNN("name");
    field.setValue(displayedName);
  } else {
    fieldGroup.setFieldValue("name", displayedName);
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

/**
 * Creates new entity instance from {@link com.haulmont.cuba.core.global.EntityLoadInfo}
 * and reset fields values
 */
protected Entity createEmptyInstance(EntityLoadInfo loadInfo) throws IllegalAccessException, InstantiationException {
  MetaClass metaClass = loadInfo.getMetaClass();
  Entity instance = metadata.create(metaClass);
  for (MetaProperty metaProperty : metaClass.getProperties()) {
    if (!metaProperty.isReadOnly())
      instance.setValue(metaProperty.getName(), null);
  }
  return instance;
}

代码示例来源:origin: com.haulmont.cuba/cuba-rest-api

/**
 * Creates new entity instance from {@link com.haulmont.cuba.core.global.EntityLoadInfo}
 * and reset fields values
 */
protected Entity createEmptyInstance(EntityLoadInfo loadInfo) throws IllegalAccessException, InstantiationException {
  MetaClass metaClass = loadInfo.getMetaClass();
  Entity instance = metadata.create(metaClass);
  for (MetaProperty metaProperty : metaClass.getProperties()) {
    if (!metaProperty.isReadOnly())
      instance.setValue(metaProperty.getName(), null);
  }
  return instance;
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

/**
 * Tries to initialize entity fields included in entity name pattern by default values
 *
 * @param entity instance
 */
protected void initNamePatternFields(Entity entity) {
  Collection<MetaProperty> properties = metadata.getTools().getNamePatternProperties(entity.getMetaClass());
  for (MetaProperty property : properties) {
    if (entity.getValue(property.getName()) == null
        && property.getType() == MetaProperty.Type.DATATYPE) {
      try {
        entity.setValue(property.getName(), property.getJavaType().newInstance());
      } catch (InstantiationException | IllegalAccessException e) {
        throw new RuntimeException("Unable to set value of name pattern field", e);
      }
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-global

protected void createEmbedded(Entity entity) {
  MetaClass metaClass = getClassNN(entity.getClass());
  for (MetaProperty property : metaClass.getProperties()) {
    if (property.getRange().isClass() && tools.isEmbedded(property)) {
      EmbeddedParameters embeddedParameters = property.getAnnotatedElement().getAnnotation(EmbeddedParameters.class);
      if (embeddedParameters != null && !embeddedParameters.nullAllowed()) {
        MetaClass embeddableMetaClass = property.getRange().asClass();
        Entity embeddableEntity = create(embeddableMetaClass);
        entity.setValue(property.getName(), embeddableEntity);
      }
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected <E extends Entity> void initializeNestedEntity(E entity, Nested container) {
  InstanceContainer masterContainer = container.getMaster();
  String property = container.getProperty();
  MetaClass masterMetaClass = masterContainer.getEntityMetaClass();
  MetaProperty metaProperty = masterMetaClass.getPropertyNN(property);
  MetaProperty inverseProp = metaProperty.getInverse();
  if (inverseProp != null) {
    Class<?> inversePropClass = extendedEntities.getEffectiveClass(inverseProp.getDomain());
    Class<?> containerEntityClass = extendedEntities.getEffectiveClass(((CollectionContainer) container).getEntityMetaClass());
    if (inversePropClass.isAssignableFrom(containerEntityClass)) {
      entity.setValue(inverseProp.getName(), masterContainer.getItem());
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-core

protected void setReferenceNull(Entity entity, MetaProperty property) {
  Range range = property.getRange();
  if (metadata.getTools().isOwningSide(property) && !range.getCardinality().isMany()) {
    if (PersistenceHelper.isLoaded(entity, property.getName())) {
      entity.setValue(property.getName(), null);
    } else {
      hardSetReferenceNull(entity, property);
    }
  }
}

代码示例来源:origin: com.haulmont.cuba/cuba-core

private void loadOne(EntityCrossDataStoreProperty entityCrossDataStoreProperty) {
  Entity entity = entityCrossDataStoreProperty.entity;
  CrossDataStoreProperty aProp = entityCrossDataStoreProperty.crossProp;
  Object id = entity.getValue(aProp.relatedPropertyName);
  LoadContext<Entity> loadContext = new LoadContext<>(aProp.property.getRange().asClass());
  loadContext.setId(id);
  if (aProp.viewProperty.getView() != null)
    loadContext.setView(aProp.viewProperty.getView());
  loadContext.setJoinTransaction(joinTransaction);
  Entity relatedEntity = dataManager.load(loadContext);
  entity.setValue(aProp.property.getName(), relatedEntity);
}

代码示例来源:origin: com.haulmont.cuba/cuba-gui

protected Entity initEntity() {
  EntityValueSource entityValueSource = (EntityValueSource) pickerField.getValueSource();
  Entity entity = AppBeans.get(Metadata.class).create(
      entityValueSource.getMetaPropertyPath().getMetaProperty().getRange().asClass());
  Entity ownerEntity = entityValueSource.getItem();
  MetaProperty inverseProp = entityValueSource.getMetaPropertyPath().getMetaProperty().getInverse();
  if (inverseProp != null) {
    entity.setValue(inverseProp.getName(), ownerEntity);
  }
  return entity;
}

相关文章