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

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

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

Entity.getTreeField介绍

暂无

代码示例

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

private EntityTree getTechnologyOperationComponents(final Entity technology) {
  return technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
}

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

private EntityTree getOperationComponentsFromTechnology(final Entity technology) {
  return technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
}

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

private List<Entity> operationComponents(Entity technology) {
  return entityTreeUtilsService.getSortedEntities(technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS));
}

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

private List<Entity> operationComponents(Entity technology) {
  return entityTreeUtilsService.getSortedEntities(technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS));
}

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

public void checkConsumingManyProductsFromOneSubOp(final StateChangeContext stateContext) {
  final Entity technology = stateContext.getOwner();
  final Map<String, Set<String>> parentChildNodeNums = technologyTreeValidationService
      .checkConsumingManyProductsFromOneSubOp(technology.getTreeField(OPERATION_COMPONENTS));
  for (Map.Entry<String, Set<String>> parentChildNodeNum : parentChildNodeNums.entrySet()) {
    for (String childNodeNum : parentChildNodeNum.getValue()) {
      stateContext.addMessage("technologies.technology.validate.global.info.consumingManyProductsFromOneSubOperations",
          StateMessageType.INFO, parentChildNodeNum.getKey(), childNodeNum);
    }
  }
}

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

public final List<Entity> buildProductInComponentList(final Entity order) {
  EntityTree operationsTree = order.getBelongsToField(OrderFields.TECHNOLOGY).getTreeField(
      TechnologyFields.OPERATION_COMPONENTS);
  return buildGenealogyProductInComponentsList(operationsTree);
}

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

private Entity getOrderTechnologyOperationComponent(final Entity order) {
  Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
  if (technology == null) {
    return null;
  } else {
    return technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS).getRoot();
  }
}

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

private Entity getOrderTechnologyOperationComponent(final Entity order) {
  Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
  if (technology == null) {
    return null;
  } else {
    Entity technologyOperationComponent = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS).getRoot();
    return technologyOperationComponent;
  }
}

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

public boolean checkIfTechnologyTreeIsSet(final StateChangeContext stateChangeContext) {
  final Entity technology = stateChangeContext.getOwner();
  final EntityTree operations = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
  if (operations.isEmpty()) {
    stateChangeContext.addValidationError("technologies.technology.validate.global.error.emptyTechnologyTree");
    return false;
  }
  return true;
}

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

public void setDefaultValuesIfEmpty(final DataDefinition dataDefinition, final Entity technology) {
  if (technology.getId() == null) {
    return;
  }
  Entity savedTechnology = dataDefinition.get(technology.getId());
  if ("02accepted".equals(technology.getStringField("state")) && "01draft".equals(savedTechnology.getStringField("state"))) {
    final EntityTree operationComponents = savedTechnology.getTreeField("operationComponents");
    for (Entity operationComponent : operationComponents) {
      setOperationComponentDefaults(operationComponent);
    }
  }
}

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

private void checkFinalProductionCountingForOrderForEach(final StateChangeContext stateChangeContext) {
  final Entity order = stateChangeContext.getOwner();
  final Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
  final List<Entity> technologyOperationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
  int productionTrackingsNumber = 0;
  for (Entity technologyOperationComponent : technologyOperationComponents) {
    if (checkIfOrderHasFinalProductionTrackings(order, technologyOperationComponent)) {
      productionTrackingsNumber++;
    }
  }
  if (order.getBooleanField(OrderFieldsPC.ALLOW_TO_CLOSE)
      && (technologyOperationComponents.size() != productionTrackingsNumber)) {
    stateChangeContext.addValidationError("orders.order.state.allowToClose.failureForEach");
  }
}

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

@Transactional
public Entity copyTechnologyTree(final Entity costCalculation) {
  deleteOperationsTreeIfExists(costCalculation);
  Entity operationsTreeContainer;
  if (costCalculation.getBelongsToField(L_ORDER) == null) {
    operationsTreeContainer = costCalculation.getBelongsToField(L_TECHNOLOGY);
  } else {
    operationsTreeContainer = costCalculation.getBelongsToField(L_ORDER).getBelongsToField(L_TECHNOLOGY);
  }
  EntityTree sourceOperationsTree = operationsTreeContainer.getTreeField(OPERATION_COMPONENTS);
  return createTechnologyInstanceForCalculation(sourceOperationsTree, costCalculation);
}

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

private Entity createTechnologyInstanceForCalculation(final EntityTree sourceTree, final Entity parentEntity) {
  checkArgument(sourceTree != null, "source is null");
  DataDefinition calculationOperationComponentDD = dataDefinitionService.get(PLUGIN_IDENTIFIER,
      MODEL_CALCULATION_OPERATION_COMPONENT);
  // drop old operation components tree
  EntityTree oldCalculationOperationComponents = parentEntity.getTreeField(L_CALCULATION_OPERATION_COMPONENTS);
  if (oldCalculationOperationComponents != null && oldCalculationOperationComponents.getRoot() != null) {
    calculationOperationComponentDD.delete(oldCalculationOperationComponents.getRoot().getId());
  }
  Entity tree = createCalculationOperationComponent(sourceTree.getRoot(), null, calculationOperationComponentDD,
      parentEntity);
  parentEntity.setField(L_CALCULATION_OPERATION_COMPONENTS, asList(tree));
  return parentEntity;
}

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

private void setParentIfRootNodeAlreadyExists(final Entity technologyOperationComponent) {
  Entity technology = technologyOperationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY);
  EntityTree tree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
  if (tree == null || tree.isEmpty()) {
    return;
  }
  EntityTreeNode rootNode = tree.getRoot();
  if ((rootNode == null)
      || (technologyOperationComponent.getBelongsToField(TechnologyOperationComponentFields.PARENT) != null)) {
    return;
  }
  technologyOperationComponent.setField(TechnologyOperationComponentFields.PARENT, rootNode);
}

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

public void validateTypeOfProductionRecordingForTechnology(final StateChangeContext stateChangeContext) {
  Entity technology = stateChangeContext.getOwner();
  if (technology != null && !stateChangeContext.getStatus().equals(StateChangeStatus.FAILURE)) {
    EntityTree tree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
    Entity mainProduct = technologyService.getMainOutputProductComponent(tree.getRoot());
    String typeOfProductionRecording = technology.getStringField(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
    if (mainProduct.getBooleanField(OperationProductOutComponentFields.SET)
        && typeOfProductionRecording.equals("03forEach")) {
      stateChangeContext.addValidationError("technologies.technology.technologyState.error.typeOfProductionRecording");
    }
  }
}

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

public boolean checkIfTechnologyHasAtLeastOneComponent(final StateChangeContext stateContext) {
  Entity technology = stateContext.getOwner();
  final Entity savedTechnology = technology.getDataDefinition().get(technology.getId());
  final EntityTree operations = savedTechnology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
  if (!operations.isEmpty()) {
    return true;
  }
  stateContext.addValidationError("technologies.technology.validate.global.error.emptyTechnologyTree");
  return false;
}

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

private Optional<Entity> getSetProductTechnology(final Long productId) {
  DataDefinition technologyDD = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER,
      TechnologiesConstants.MODEL_TECHNOLOGY);
  Entity masterTechnology = technologyDD.find().add(SearchRestrictions.eq(TechnologyFields.PRODUCT + ".id", productId))
      .add(SearchRestrictions.eq(TechnologyFields.MASTER, true)).uniqueResult();
  if (masterTechnology != null) {
    EntityTree operationComponents = masterTechnology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
    boolean isSet = operationComponents.getRoot()
        .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS).get(0)
        .getBooleanField(OperationProductOutComponentFields.SET);
    if (isSet) {
      return Optional.of(masterTechnology);
    }
  }
  return Optional.empty();
}

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

public void validateTypeOfProductionRecordingForOrder(final StateChangeContext stateChangeContext) {
    if(parameterService.getParameter().getBooleanField(ParameterFieldsO.CREATE_SET_ELEMENTS_ON_ACCEPT)) {
      Entity order = stateChangeContext.getOwner();
      Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY);
      if (technology != null && !stateChangeContext.getStatus().equals(StateChangeStatus.FAILURE)) {
        EntityTree tree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
        Entity mainProduct = technologyService.getMainOutputProductComponent(tree.getRoot());
        String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING);
        if (typeOfProductionRecording != null && mainProduct.getBooleanField(OperationProductOutComponentFields.SET) && typeOfProductionRecording.equals("03forEach")) {
          stateChangeContext
              .addValidationError("technologies.technology.technologyState.error.typeOfProductionRecording");
        }
      }
    }
  }
}

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

private void deleteOperationsTreeIfExists(final Entity costCalculation) {
  Entity yetAnotherCostCalculation = costCalculation.getDataDefinition().get(costCalculation.getId());
  EntityTree existingOperationsTree = yetAnotherCostCalculation.getTreeField(L_CALCULATION_OPERATION_COMPONENTS);
  if (existingOperationsTree == null || existingOperationsTree.getRoot() == null) {
    return;
  }
  debug("existing calculation operation components tree will be removed..");
  EntityTreeNode existingOperationsTreeRoot = existingOperationsTree.getRoot();
  existingOperationsTreeRoot.getDataDefinition().delete(existingOperationsTreeRoot.getId());
}

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

public void checkIfEveryOperationHasInComponents(final StateChangeContext stateContext) {
  Entity technology = stateContext.getOwner();
  final Entity savedTechnology = technology.getDataDefinition().get(technology.getId());
  final EntityTree operations = savedTechnology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);
  for (Entity toc : operations) {
    if (toc.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS).isEmpty()) {
      stateContext.addValidationError("technologies.technology.validate.global.error.noInputComponents", toc
          .getBelongsToField(TechnologyOperationComponentFields.OPERATION).getStringField(OperationFields.NUMBER),
          toc.getStringField(TechnologyOperationComponentFields.NODE_NUMBER));
      return;
    }
  }
}

相关文章