com.qcadoo.model.api.Entity.setId()方法的使用及代码示例

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

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

Entity.setId介绍

暂无

代码示例

代码示例来源:origin: qcadoo/mes

private boolean addToList(final List<Entity> tree, final Entity child, final boolean makeIdsUnique) {
  child.setField(PRIORITY, 1);
  child.setField(ENTITY_TYPE, L_BATCH);
  if (checkIfTreeContainsEntity(tree, child)) {
    return false;
  } else {
    if (makeIdsUnique) {
      child.setId((long) tree.size());
    }
    tree.add(child);
    return true;
  }
}

代码示例来源:origin: qcadoo/mes

private void addChild(List<Entity> tree, final Entity child, final Entity parent) {
  child.setField(FactoryStructureElementFields.PARENT, parent);
  child.setId((long) tree.size() + 1);
  child.setField(FactoryStructureElementFields.NODE_NUMBER, child.getId());
  child.setField(FactoryStructureElementFields.PRIORITY, 1);
  tree.add(child);
}

代码示例来源:origin: qcadoo/mes

private Entity copyReferencedTechnologyOperations(final Entity node, final Entity technology) {
  Entity copy = node.copy();
  copy.setId(null);
  copy.setField(TechnologyOperationComponentFields.PARENT, null);
  copy.setField(TechnologyOperationComponentFields.TECHNOLOGY, technology);
  for (Entry<String, Object> entry : node.getFields().entrySet()) {
    Object value = entry.getValue();
    if (value instanceof EntityList) {
      EntityList entities = (EntityList) value;
      List<Entity> copies = Lists.newArrayList();
      for (Entity entity : entities) {
        copies.add(copyReferencedTechnologyOperations(entity, technology));
      }
      copy.setField(entry.getKey(), copies);
    }
  }
  return copy;
}

代码示例来源:origin: qcadoo/mes

@Transactional(propagation = Propagation.REQUIRES_NEW)
private Either<Entity, Void> tryValidateDailyProgress(final Entity dailyProgress) {
  Entity savedDailyProgress = saved(dailyProgress);
  TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  // reset id to avoid 'entity cannot be found' exceptions.
  savedDailyProgress.setId(dailyProgress.getId());
  if (savedDailyProgress.isValid()) {
    return Either.right(null);
  }
  return Either.left(savedDailyProgress);
}

代码示例来源:origin: qcadoo/mes

private void fillPositions(Entity location, Entity document, DocumentBuilder pzBuilder) {
  List<Entity> positions = document.getHasManyField(DocumentFields.POSITIONS);
  positions.forEach(pos -> {
    Entity pzPosition = pos.copy();
    pzPosition.setId(null);
    pzPosition.setField(PositionFields.DOCUMENT, null);
    pzPosition.setField(PositionFields.RESOURCE, null);
    pzPosition.setField(PositionFields.TYPE_OF_PALLET, null);
    pzPosition.setField(PositionFields.PALLET_NUMBER, null);
    Optional<Entity> maybyStorageLocation = findStorageLocationForProduct(pos.getBelongsToField(PositionFields.PRODUCT),
        location);
    if (maybyStorageLocation.isPresent()) {
      pzPosition.setField(PositionFields.STORAGE_LOCATION, maybyStorageLocation.get());
    } else {
      pzPosition.setField(PositionFields.STORAGE_LOCATION, null);
    }
    pzBuilder.addPosition(pzPosition);
  });
}

代码示例来源:origin: qcadoo/mes

private Entity generateFormEntity(final ViewDefinitionState view) {
  DataDefinition dd = dataDefinitionService.get(BasicConstants.PLUGIN_IDENTIFIER, BasicConstants.MODEL_PRODUCT);
  FormComponent form = getForm(view);
  Entity formEntity = form.getEntity();
  GridComponent parentsGrid = (GridComponent) view.getComponentByReference("parents");
  if (parentsGrid.getSelectedEntities().isEmpty()) {
    return null;
  }
  Long productId = parentsGrid.getSelectedEntities().get(0).getId();
  if (productId == null) {
    throw new FormValidationException("basic.productFamiliesTree.noProductSelected");
  }
  Entity product = dd.get(productId);
  List<Entity> tree = productsFamiliesTreeService.getHierarchyProductsTree(product);
  EntityTree entityTree = EntityTreeUtilsService.getDetachedEntityTree(tree);
  formEntity.setId(productId);
  formEntity.setField(PRODUCT_FAMILY_CHILDREN_TREE, entityTree);
  return formEntity;
}

代码示例来源:origin: qcadoo/mes

if (shouldBeCorrected) {
  dailyProgress = dailyProgress.copy();
  dailyProgress.setId(null);

代码示例来源:origin: qcadoo/mes

public void generateTimeGaps(final ViewDefinitionState viewState, final ComponentState formState, final String[] args)
    throws ParseException {
  FormComponent form = (FormComponent) formState;
  Entity contextEntity = form.getPersistedEntityWithIncludedFormValues();
  // We don't want to reuse contexts - in case of the user working with many browser tabs to compare a couple of results
  contextEntity.setId(null);
  contextEntity.setField(TimeGapsContextFields.TIME_GAPS, Collections.<Entity> emptyList());
  // Call validation
  contextEntity = contextEntity.getDataDefinition().save(contextEntity);
  if (!contextEntity.isValid()) {
    clearSummaryFields(contextEntity);
    form.setEntity(contextEntity);
    return;
  }
  // Generate & persist results
  TimeGapsSearchResult searchResult = performGeneration(contextEntity);
  Entity persistedContext = persistResults(contextEntity, searchResult);
  if (persistedContext.isValid()) {
    // Show 'time gaps' tab
    WindowComponent window = (WindowComponent) findComponentByReferenceName(viewState, "window");
    window.setActiveTab("timeGaps");
  }
  form.setEntity(persistedContext);
}

代码示例来源:origin: qcadoo/mes

public void generateBalance(final ViewDefinitionState viewState, final ComponentState formState, final String[] args) {
  FormComponent form = (FormComponent) formState;
  Entity contextEntity = form.getPersistedEntityWithIncludedFormValues();
  // We don't want to reuse contexts - in case of the user working with many browser tabs to compare a couple of results
  contextEntity.setId(null);
  contextEntity.setField(BalanceContextFields.BALANCES, Collections.<Entity> emptyList());
  // Call validation
  contextEntity = contextEntity.getDataDefinition().save(contextEntity);
  if (!contextEntity.isValid()) {
    form.setEntity(contextEntity);
    return;
  }
  BalanceGenerationStrategy strategy = resolveBalanceGenerationStrategy(contextEntity);
  List<Entity> balances = productionBalancePerShiftGenerator.generate(strategy);
  contextEntity.setField(BalanceContextFields.BALANCES, balances);
  Entity persistedContext = contextEntity.getDataDefinition().save(contextEntity);
  if (persistedContext.isValid()) {
    // Show 'balances' tab
    WindowComponent window = (WindowComponent) viewState.getComponentByReference("window");
    window.setActiveTab("balances");
  }
  form.setEntity(persistedContext);
}

相关文章