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

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

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

Entity.isValid介绍

暂无

代码示例

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

@Override
  public boolean apply(final Entity progressForDay) {
    return progressForDay.isValid();
  }
};

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

private <M extends StateService> boolean hookOnAfterSave(Entity entity, Collection<M> services, String sourceState,
    String targetState, Entity stateChangeEntity, StateChangeEntityDescriber describer) {
  for (StateService service : services) {
    entity = service.onAfterSave(entity, sourceState, targetState, stateChangeEntity, describer);
  }
  return entity.isValid();
}

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

private boolean setStateChangeEntity(final Entity stateChange) {
  Preconditions.checkNotNull(stateChange);
  if (stateChange.isValid()) {
    final Entity savedStateChange = describer.getDataDefinition().save(stateChange);
    if (savedStateChange.isValid()) {
      this.entity = savedStateChange;
      return true;
    }
  }
  markAsFailureByValidation(stateChange);
  return false;
}

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

private Optional<Entity> saveCoverage(Entity mcfo) {
  mcfo = mcfo.getDataDefinition().save(mcfo);
  if (!mcfo.isValid()) {
    mcfo = null;
  }
  return Optional.fromNullable(mcfo);
}

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

private Entity createParameter(final DataDefinition dataDefinition) {
  Entity parameter = dataDefinition.create();
  parameter = dataDefinition.save(parameter);
  Preconditions.checkState(parameter.isValid(), "Parameter entity has validation errors! " + parameter);
  return parameter;
}

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

private Entity saveAndValidate(final Entity entity) {
  if (entity == null) {
    return null;
  }
  Entity saved = entity.getDataDefinition().save(entity);
  if (!saved.isValid()) {
    throw new RuntimeException(String.format("Error on save state entity: %s", saved.getErrors()));
  }
  return saved;
}

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

private void removeShowLastResultsFlag(final Entity assignmentToShift) {
  assignmentToShift.setField(AssignmentToShiftFields.SHOW_LAST_STATE_CHANGE_RESULT, false);
  Entity savedAssignmentToShift = assignmentToShift.getDataDefinition().save(assignmentToShift);
  if (!savedAssignmentToShift.isValid() && LOG.isWarnEnabled()) {
    LOG.warn("Can't remove 'showLastStateChangeResults' flag because of validation errors in entity: "
        + savedAssignmentToShift);
  }
}

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

private boolean isEntityValid(final Entity entity) {
  boolean isValid = entity.isValid();
  if (!isValid) {
    ValidationMessageHelper.copyErrorsFromEntity(this, entity);
    setStatus(StateChangeStatus.FAILURE);
  }
  return isValid;
}

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

private void populateImportStatusWithEntityErrors(Entity entity) {
    if (!entity.isValid()) {
      for (Map.Entry<String, ErrorMessage> entry : entity.getErrors().entrySet()) {
        importStatus.addError(
            new ImportError(
                currentRow, entry.getKey(), entry.getValue().getMessage(), entry.getValue().getVars())
        );
      }
    }
  }
}

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

private boolean setNewParent(Entity toc, final Entity newParent) {
  toc.setField(TechnologyOperationComponentFields.PARENT, newParent);
  Entity saved = getTocDataDefinition().save(toc);
  return saved.isValid();
}

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

private void addValidationErrorsToForm(final FormComponent form, final List<Entity> messagesList) {
  final Entity entity = form.getEntity();
  final List<Entity> messages = Lists.newArrayList(messagesList);
  CollectionUtils.filter(messages, VALIDATION_MESSAGES_PREDICATE);
  for (Entity message : messages) {
    assignMessageToEntity(entity, message);
  }
  if (!entity.isValid()) {
    form.addMessage("qcadooView.message.saveFailedMessage", MessageType.FAILURE);
  }
  form.setEntity(entity);
}

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

@Transactional(propagation = Propagation.REQUIRES_NEW)
private void tryGeneratePPS(final Entity order) {
  Date startDate = findStartDate(order);
  generateEmptyPpsForOrder(order);
  order.setField("generatePPS", true);
  order.setField(OrderFields.START_DATE, startDate);
  order.setField(OrderFields.FINISH_DATE, new DateTime(order.getDateField(OrderFields.START_DATE)).plusDays(1).toDate());
  Entity storedOrder = order.getDataDefinition().save(order);
  if (!storedOrder.isValid()) {
    throw new EntityRuntimeException(storedOrder);
  }
}

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

private Either<String, Entity> copy(final Entity technology) {
  DataDefinition technologyDD = technology.getDataDefinition();
  Entity copy = technologyDD.copy(technology.getId()).get(0);
  if (copy.isValid()) {
    return Either.right(copy);
  }
  return Either.left("Cannot copy technology due to validation errors.");
}

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

public void createDocumentsForTheReceivedProducts(final StateChangeContext stateChangeContext) {
  final Entity delivery = stateChangeContext.getOwner();
  try {
    createDocuments(stateChangeContext, delivery);
    if (!delivery.isValid()) {
      stateChangeContext.setStatus(StateChangeStatus.FAILURE);
    }
  } catch (Exception ex) {
    stateChangeContext.addValidationError("productFlowThruDivision.deliveries.warehouseIssue.issuesCreated.error");
  }
}

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

private Either<String, Entity> trySave(final Entity entity) {
  DataDefinition dataDefinition = entity.getDataDefinition();
  Entity savedEntity = dataDefinition.save(entity);
  if (savedEntity.isValid()) {
    return Either.right(savedEntity);
  }
  return Either.left(String.format("Cannot save %s.%s because of validation errors", dataDefinition.getPluginIdentifier(),
      dataDefinition.getName()));
}

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

private Either<String, Entity> trySave(final Entity entity) {
  DataDefinition dataDef = entity.getDataDefinition();
  Entity savedEntity = dataDef.save(entity);
  if (savedEntity.isValid()) {
    return Either.right(savedEntity);
  }
  return Either.left(String.format("Cannot save %s.%s because of validation errors", dataDef.getPluginIdentifier(),
      dataDef.getName()));
}

代码示例来源: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 Either<String, Entity> saveOperationComponent(final Entity entity) {
  Entity savedEntity = entity.getDataDefinition().save(entity);
  if (savedEntity.isValid()) {
    return Either.right(savedEntity);
  }
  return Either.left(String.format(VALIDATION_ERR_TEMPLATE, entity.getDataDefinition().getName(), entity.getId()));
}

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

private Either<String, ContextId> generate(final GeneratorView generatorView) {
  Entity context = generatorView.getFormEntity();
  Entity savedContext = context.getDataDefinition().save(context);
  if (savedContext.isValid()) {
    return performGeneration(generatorView, savedContext);
  }
  generatorView.setFormEntity(savedContext);
  return Either.left("Context has validation errors");
}

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

private Either<String, TechnologyId> setupTechnologyNumberAndName(final Entity technology, final Entity product) {
  technology.setField(TechnologyFields.NUMBER, technologyNameAndNumberGenerator.generateNumber(product));
  technology.setField(TechnologyFields.NAME, technologyNameAndNumberGenerator.generateName(product));
  Entity savedTech = technology.getDataDefinition().save(technology);
  if (savedTech.isValid()) {
    return Either.right(new TechnologyId(savedTech.getId()));
  } else {
    return Either.left("Cannot setup technology name and number due to validation errors");
  }
}

相关文章