Exemplo n.º 1
0
  /**
   * Update and persist the tag type per specified update request.
   *
   * @param tagTypeEntity the tag type entity
   * @param request the tag type update request
   */
  private void updateTagTypeEntity(TagTypeEntity tagTypeEntity, TagTypeUpdateRequest request) {
    tagTypeEntity.setDisplayName(request.getDisplayName());
    tagTypeEntity.setOrderNumber(request.getTagTypeOrder());

    // Persist and refresh the entity.
    tagTypeDao.saveAndRefresh(tagTypeEntity);
  }
Exemplo n.º 2
0
 /**
  * Creates and persists a new tag type entity.
  *
  * @param tagTypeCode the tag type code
  * @param displayName the display name
  * @param tagTypeOrder the tag type order number
  * @return the newly created tag type entity
  */
 private TagTypeEntity createTagTypeEntity(
     String tagTypeCode, String displayName, int tagTypeOrder) {
   TagTypeEntity tagTypeEntity = new TagTypeEntity();
   tagTypeEntity.setCode(tagTypeCode);
   tagTypeEntity.setDisplayName(displayName);
   tagTypeEntity.setOrderNumber(tagTypeOrder);
   return tagTypeDao.saveAndRefresh(tagTypeEntity);
 }
Exemplo n.º 3
0
  /**
   * Creates the tag type registration from the persisted entity.
   *
   * @param tagTypeEntity the tag type registration entity
   * @param includeDisplayName specifies to include display name field
   * @param includeTagTypeOrder specifies to include tag type order field
   * @return the tag type registration
   */
  private TagType createTagTypeFromEntity(
      TagTypeEntity tagTypeEntity, boolean includeDisplayName, boolean includeTagTypeOrder) {
    TagType tagType = new TagType();

    TagTypeKey tagTypeKey = new TagTypeKey();
    tagType.setTagTypeKey(tagTypeKey);
    tagTypeKey.setTagTypeCode(tagTypeEntity.getCode());

    if (includeDisplayName) {
      tagType.setDisplayName(tagTypeEntity.getDisplayName());
    }

    if (includeTagTypeOrder) {
      tagType.setTagTypeOrder(tagTypeEntity.getOrderNumber());
    }

    return tagType;
  }
Exemplo n.º 4
0
  @Override
  public TagType updateTagType(TagTypeKey tagTypeKey, TagTypeUpdateRequest request) {
    // Perform validation and trim.
    tagTypeHelper.validateTagTypeKey(tagTypeKey);

    // Perform validation and trim the alternate key parameters.
    validateTagTypeUpdateRequest(request);

    // Retrieve and ensure that a tag type already exists with the specified key.
    TagTypeEntity tagTypeEntity = tagTypeDaoHelper.getTagTypeEntity(tagTypeKey);

    // Validate the display name does not already exist for another tag type.
    if (!StringUtils.equalsIgnoreCase(tagTypeEntity.getDisplayName(), request.getDisplayName())) {
      // Validate that the description is different.
      tagTypeDaoHelper.assertTagTypeDisplayNameDoesNotExist(request.getDisplayName());
    }

    // Update and persist the tag type entity.
    updateTagTypeEntity(tagTypeEntity, request);

    // Create and return the tag type from the persisted entity.
    return createTagTypeFromEntity(tagTypeEntity);
  }