コード例 #1
0
ファイル: TechnologyServiceO.java プロジェクト: Kudlaty01/mes
  private void updateTechnology(final Entity technology) {
    String number = technology.getStringField(TechnologyFields.NUMBER);
    Entity product = technology.getBelongsToField(TechnologyFields.PRODUCT);

    technology.setField(TechnologyFields.NAME, makeTechnologyName(number, product));
    technology.setField(TechnologyFields.TECHNOLOGY_PROTOTYPE, null);
    technology.setField(
        TechnologyFields.TECHNOLOGY_TYPE, TechnologyType.WITH_OWN_TECHNOLOGY.getStringValue());

    EntityTree operationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS);

    if ((operationComponents != null) && !operationComponents.isEmpty()) {
      EntityTreeNode root = operationComponents.getRoot();

      root.getDataDefinition().delete(root.getId());
    }

    technology.setField(TechnologyFields.OPERATION_COMPONENTS, Lists.newArrayList());

    technology.getDataDefinition().save(technology);

    if (TechnologyStateStringValues.CHECKED.equals(
        technology.getStringField(TechnologyFields.STATE))) {
      changeTechnologyState(technology, TechnologyStateStringValues.DRAFT);
    }
  }
コード例 #2
0
  private EntityTreeNode mockOperationComponent(
      final Long id,
      final String nodeNumber,
      final Collection<Entity> inputProducts,
      final Collection<Entity> outputProducts,
      final List<EntityTreeNode> subOperations) {
    EntityTreeNode operationComponent = mock(EntityTreeNode.class);

    given(operationComponent.getId()).willReturn(id);

    EntityList inputProductsList = mockProductComponentsList(inputProducts);
    given(operationComponent.getHasManyField(OPERATION_PRODUCT_IN_COMPONENTS))
        .willReturn(inputProductsList);
    given(operationComponent.getField(OPERATION_PRODUCT_IN_COMPONENTS))
        .willReturn(inputProductsList);

    EntityList outputProductsList = mockProductComponentsList(outputProducts);
    given(operationComponent.getHasManyField(OPERATION_PRODUCT_OUT_COMPONENTS))
        .willReturn(outputProductsList);
    given(operationComponent.getField(OPERATION_PRODUCT_OUT_COMPONENTS))
        .willReturn(outputProductsList);

    given(operationComponent.getField(NODE_NUMBER)).willReturn(nodeNumber);
    given(operationComponent.getStringField(NODE_NUMBER)).willReturn(nodeNumber);

    given(operationComponent.getChildren()).willReturn(subOperations);

    return operationComponent;
  }