public static JSONObject toJSONObject(AssetTag model) {
    JSONObject jsonObject = JSONFactoryUtil.createJSONObject();

    jsonObject.put("tagId", model.getTagId());
    jsonObject.put("groupId", model.getGroupId());
    jsonObject.put("companyId", model.getCompanyId());
    jsonObject.put("userId", model.getUserId());
    jsonObject.put("userName", model.getUserName());

    Date createDate = model.getCreateDate();

    String createDateJSON = StringPool.BLANK;

    if (createDate != null) {
      createDateJSON = String.valueOf(createDate.getTime());
    }

    jsonObject.put("createDate", createDateJSON);

    Date modifiedDate = model.getModifiedDate();

    String modifiedDateJSON = StringPool.BLANK;

    if (modifiedDate != null) {
      modifiedDateJSON = String.valueOf(modifiedDate.getTime());
    }

    jsonObject.put("modifiedDate", modifiedDateJSON);
    jsonObject.put("name", model.getName());
    jsonObject.put("assetCount", model.getAssetCount());

    return jsonObject;
  }
Beispiel #2
0
  @Override
  public AssetTag incrementAssetCount(long tagId, long classNameId)
      throws PortalException, SystemException {

    AssetTag tag = assetTagPersistence.findByPrimaryKey(tagId);

    tag.setAssetCount(tag.getAssetCount() + 1);

    assetTagPersistence.update(tag);

    assetTagStatsLocalService.updateTagStats(tagId, classNameId);

    return tag;
  }