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

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

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

Entity.addError介绍

暂无

代码示例

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

public boolean checkIfIsMoreThatFiveDays(final DataDefinition assignmentToShiftReportDD, final Entity assignmentToShiftReport) {
  int days = assignmentToShiftXlsHelper.getNumberOfDaysBetweenGivenDates(assignmentToShiftReport);
  if (days > 5) {
    assignmentToShiftReport.addError(assignmentToShiftReportDD.getField(DATE_FROM),
        "assignmentToShift.assignmentToShift.report.onlyFiveDays");
    assignmentToShiftReport.addError(assignmentToShiftReportDD.getField(DATE_TO),
        "assignmentToShift.assignmentToShift.report.onlyFiveDays");
    return false;
  }
  return true;
}

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

public boolean checkEanUniqueness(final DataDefinition productDD, final FieldDefinition eanFieldDefinition,
    final Entity product, final Object eanOldValue, final Object eanNewValue) {
  String ean = (String) eanNewValue;
  if (StringUtils.isEmpty(ean) || ObjectUtils.equals(eanOldValue, ean)) {
    return true;
  }
  if (productWithEanAlreadyExists(productDD, ean)) {
    product.addError(eanFieldDefinition, "qcadooView.validate.field.error.duplicated");
    return false;
  }
  return true;
}

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

private void addErrorIfNull(Entity entity, DataDefinition dataDefinition, String fieldName, String error) {
    if (entity.getField(fieldName) == null) {
      entity.addError(dataDefinition.getField(fieldName), error);
    }
  }
}

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

private void checkMissing(Entity position, String fieldname, DataDefinition positionDataDefinition) {
  if (position.getField(fieldname) == null) {
    position.addError(positionDataDefinition.getField(fieldname), "qcadooView.validate.field.error.missing");
  }
}

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

public boolean validatesWith(final DataDefinition parameterDD, final Entity technology) {
  if (technology.getStringField(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING) == null) {
    technology.addError(parameterDD.getField(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING),
        "qcadooView.validate.field.error.missing");
    return false;
  }
  return true;
}

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

private void copyPositionErrors(final Entity position, final Entity newPosition) {
  for (Map.Entry<String, ErrorMessage> error : newPosition.getErrors().entrySet()) {
    position.addError(position.getDataDefinition().getField(error.getKey()), error.getValue().getMessage());
  }
}

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

private boolean validateRequiredComment(final DataDefinition evenStateChangetDD, final Entity eventStateChange) {
    String comment = eventStateChange.getStringField(PlannedEventStateChangeFields.COMMENT);

    if (eventStateChange.getBooleanField(PlannedEventStateChangeFields.COMMENT_REQUIRED) && Strings.isNullOrEmpty(comment)) {
      eventStateChange.addError(evenStateChangetDD.getField(PlannedEventStateChangeFields.COMMENT),
          "cmmsMachineParts.plannedEvent.state.commentRequired");
      return false;
    }

    return true;
  }
}

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

private boolean checkOperatorWorkTime(final DataDefinition staffWorkTimeDD, final Entity staffWorkTime) {
  Date dateFrom = staffWorkTime.getDateField(StaffWorkTimeFields.EFFECTIVE_EXECUTION_TIME_START);
  Date dateTo = staffWorkTime.getDateField(StaffWorkTimeFields.EFFECTIVE_EXECUTION_TIME_END);
  if (dateFrom == null || dateTo == null || dateTo.after(dateFrom)) {
    return true;
  }
  staffWorkTime.addError(staffWorkTimeDD.getField(StaffWorkTimeFields.EFFECTIVE_EXECUTION_TIME_END),
      "productionCounting.productionTracking.productionTrackingError.effectiveExecutionTimeEndBeforeEffectiveExecutionTimeStart");
  return false;
}

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

private boolean checkCoverageDates(final DataDefinition materialRequirementCoverageDD,
    final Entity materialRequirementCoverage) {
  Date actualDate = materialRequirementCoverage.getDateField(CoverageForOrderFields.ACTUAL_DATE);
  Date coverageToDate = materialRequirementCoverage.getDateField(CoverageForOrderFields.COVERAGE_TO_DATE);
  if (coverageToDate.before(actualDate)) {
    materialRequirementCoverage.addError(materialRequirementCoverageDD.getField(CoverageForOrderFields.COVERAGE_TO_DATE),
        "materialRequirementCoverageForOrder.coverageForOrder.covarageToDate.isBeforeActualDate");
    return false;
  }
  return true;
}

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

private boolean checkTimeRange(final DataDefinition productionTrackingDD, final Entity productionTracking) {
  Date timeRangeFrom = productionTracking.getDateField(ProductionTrackingFields.TIME_RANGE_FROM);
  Date timeRangeTo = productionTracking.getDateField(ProductionTrackingFields.TIME_RANGE_TO);
  if (timeRangeFrom == null || timeRangeTo == null || timeRangeTo.after(timeRangeFrom)) {
    return true;
  }
  productionTracking.addError(productionTrackingDD.getField(ProductionTrackingFields.TIME_RANGE_TO),
      "productionCounting.productionTracking.productionTrackingError.timeRangeToBeforetumeRangeFrom");
  return false;
}

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

public boolean checkIfDevisionChanged(final DataDefinition workstationDD, final FieldDefinition divisionFD,
    final Entity workstation, final Object divisionOldValue, final Object divisionNewValue) {
  Entity divisionOld = (Entity) divisionOldValue;
  Entity divisionNew = (Entity) divisionNewValue;
  if ((divisionOld != null) && (divisionNew != null) && !(divisionOld.getId().equals(divisionNew.getId()))) {
    workstation.addError(workstationDD.getField(WorkstationFields.DIVISION), "basic.workstation.error.divisionIsUsed");
    return false;
  }
  return true;
}

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

public boolean validateDates(final DataDefinition orderDD, final Entity order) {
  Date effectiveDateFrom = order.getDateField(OrderFields.EFFECTIVE_DATE_FROM);
  Date effectiveDateTo = order.getDateField(OrderFields.EFFECTIVE_DATE_TO);
  if ((effectiveDateFrom != null) && (effectiveDateTo != null) && effectiveDateTo.before(effectiveDateFrom)) {
    order.addError(orderDD.getField(OrderFields.EFFECTIVE_DATE_TO), "orders.validate.global.error.effectiveDateTo");
    return false;
  }
  return true;
}

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

private boolean validateForRevokedStatus(final DataDefinition evenStateChangetDD, final Entity eventStateChange) {
  String comment = eventStateChange.getStringField(MaintenanceEventStateChangeFields.COMMENT);
  if (eventStateChange.getBooleanField(MaintenanceEventStateChangeFields.COMMENT_REQUIRED)
      && Strings.isNullOrEmpty(comment)) {
    eventStateChange.addError(evenStateChangetDD.getField(MaintenanceEventStateChangeFields.COMMENT),
        "cmmsMachineParts.maintenanceEvent.state.commentRequired");
    return false;
  }
  return true;
}

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

private boolean checkOperatorWorkTime(final DataDefinition plannedEventDD, final Entity plannedEvent) {
  Date startDate = plannedEvent.getDateField(PlannedEventFields.START_DATE);
  Date finishDate = plannedEvent.getDateField(PlannedEventFields.FINISH_DATE);
  if (startDate == null || finishDate == null || finishDate.after(startDate)) {
    return true;
  }
  plannedEvent.addError(plannedEventDD.getField(PlannedEventFields.FINISH_DATE),
      "cmmsMachineParts.plannedEventDetails.error.wrongDateOrder");
  return false;
}

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

public boolean checkIfLocationIsWarehouse(final DataDefinition resourceDD, final Entity resource) {
  Entity location = resource.getBelongsToField(LOCATION);
  if (location != null) {
    String type = location.getStringField(TYPE);
    if (!"02warehouse".equals(type)) {
      resource.addError(resourceDD.getField(LOCATION),
          "materialFlowResources.validate.global.error.locationIsNotWarehouse");
      return false;
    }
  }
  return true;
}

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

public boolean validate(final DataDefinition deliveredProductDD, final Entity deliveredProduct) {
  Date productionDate = deliveredProduct.getDateField(DeliveredProductFieldsDTMF.PRODUCTION_DATE);
  Date expirationDate = deliveredProduct.getDateField(DeliveredProductFieldsDTMF.EXPIRATION_DATE);
  if (productionDate != null && expirationDate != null) {
    if (productionDate.after(expirationDate)) {
      deliveredProduct.addError(deliveredProductDD.getField(DeliveredProductFieldsDTMF.EXPIRATION_DATE),
          "materialFlow.error.position.expirationDate.lessThenProductionDate");
      return false;
    }
  }
  return palletValidatorService.validatePalletForDeliveredProduct(deliveredProduct);
}

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

public boolean checkIfParentIsFamily(final DataDefinition productDD, final Entity product) {
  Entity parent = product.getBelongsToField(ProductFields.PARENT);
  if (parent == null) {
    return true;
  }
  if (ProductFamilyElementType.PRODUCTS_FAMILY.getStringValue().equals(parent.getStringField(ProductFields.ENTITY_TYPE))) {
    return true;
  } else {
    product.addError(productDD.getField(PARENT), "basic.product.parent.parentIsNotFamily");
    return false;
  }
}

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

public boolean hasAlgorithm(final DataDefinition dataDefinition, final Entity entity) {
  if (LocationType.WAREHOUSE.equals(LocationType.parseString(entity.getStringField(LocationFields.TYPE)))
      && StringUtils.isEmpty(entity.getStringField(LocationFieldsMFR.ALGORITHM))) {
    entity.addError(dataDefinition.getField(LocationFieldsMFR.ALGORITHM), "qcadooView.validate.field.error.missing");
    return false;
  }
  return true;
}

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

public boolean validate(final DataDefinition dataDefinition, final Entity issue) {
  Entity warehouseIssue = issue.getBelongsToField(IssueFields.WAREHOUSE_ISSUE);
  if (issue.getBelongsToField(IssueFields.LOCATION).getId()
      .equals(warehouseIssue.getBelongsToField(WarehouseIssueFields.PLACE_OF_ISSUE).getId())) {
    issue.addError(dataDefinition.getField(IssueFields.LOCATION),
        "productFlowThruDivision.issue.locationFromAndToIsEquals");
  }
  if (!issue.isValid()) {
    return false;
  }
  return true;
}

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

private boolean locationUniqueToDelivery(Entity orderedProductReservation) {
  Entity orderedProduct = orderedProductReservation.getBelongsToField(OrderedProductReservationFields.ORDERED_PRODUCT);
  Entity delivery = orderedProduct.getBelongsToField(OrderedProductFields.DELIVERY);
  Entity deliveryLocation = delivery.getBelongsToField(DeliveryFields.LOCATION);
  Entity reservationLocation = orderedProductReservation.getBelongsToField(OrderedProductReservationFields.LOCATION);
  boolean locationOtherThenDelivery = deliveryLocation == null || !deliveryLocation.getId().equals(reservationLocation.getId());
  if (!locationOtherThenDelivery) {
    FieldDefinition locationField = orderedProductReservation.getDataDefinition().getField(OrderedProductReservationFields.LOCATION);
    orderedProductReservation.addError(locationField, "deliveries.deliveredProductReservation.error.locationNotUniqueToDelivery");
  }
  return locationOtherThenDelivery;
}

相关文章