private static Optional<ComponentUpdateDto> compareForUpdate(ComponentDto existing, ComponentDto target) { boolean hasDifferences = !StringUtils.equals(existing.getCopyResourceUuid(), target.getCopyResourceUuid()) || !StringUtils.equals(existing.description(), target.description()) || !StringUtils.equals(existing.getDbKey(), target.getDbKey()) || !existing.isEnabled() || !StringUtils.equals(existing.getUuidPath(), target.getUuidPath()) || !StringUtils.equals(existing.language(), target.language()) || !StringUtils.equals(existing.longName(), target.longName()) || !StringUtils.equals(existing.moduleUuid(), target.moduleUuid()) || !StringUtils.equals(existing.moduleUuidPath(), target.moduleUuidPath()) || !StringUtils.equals(existing.name(), target.name()) || !StringUtils.equals(existing.path(), target.path()) || !StringUtils.equals(existing.scope(), target.scope()) || !StringUtils.equals(existing.qualifier(), target.qualifier()); ComponentUpdateDto update = null; if (hasDifferences) { update = ComponentUpdateDto .copyFrom(target) .setBChanged(true); } return ofNullable(update); }
private void updateDb(ComponentDto component) { ComponentUpdateDto updateComponent = ComponentUpdateDto.copyFrom(component); updateComponent.setBChanged(true); dbClient.componentDao().update(dbSession, updateComponent); dbClient.componentDao().applyBChangesForRootComponentUuid(dbSession, component.getRootUuid()); dbSession.commit(); }
private static Optional<ComponentUpdateDto> compareForUpdate(ComponentDto existing, ComponentDto target) { boolean hasDifferences = !StringUtils.equals(existing.getCopyResourceUuid(), target.getCopyResourceUuid()) || !StringUtils.equals(existing.description(), target.description()) || !existing.isEnabled() || !StringUtils.equals(existing.getUuidPath(), target.getUuidPath()) || !StringUtils.equals(existing.language(), target.language()) || !StringUtils.equals(existing.longName(), target.longName()) || !StringUtils.equals(existing.moduleUuid(), target.moduleUuid()) || !StringUtils.equals(existing.moduleUuidPath(), target.moduleUuidPath()) || !StringUtils.equals(existing.name(), target.name()) || !StringUtils.equals(existing.path(), target.path()) || !StringUtils.equals(existing.qualifier(), target.qualifier()); ComponentUpdateDto update = null; if (hasDifferences) { update = ComponentUpdateDto .copyFrom(target) .setBChanged(true); } return ofNullable(update); }