protected void addExpandoValueToPage(WikiPage page) throws Exception {
    ExpandoValue value =
        ExpandoTestUtil.addValue(
            PortalUtil.getClassNameId(WikiPage.class),
            page.getPrimaryKey(),
            RandomTestUtil.randomString());

    ExpandoBridge expandoBridge = page.getExpandoBridge();

    ExpandoColumn column = value.getColumn();

    expandoBridge.addAttribute(column.getName(), ExpandoColumnConstants.STRING, value.getString());
  }
  /**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static ExpandoValue toModel(ExpandoValueSoap soapModel) {
    ExpandoValue model = new ExpandoValueImpl();

    model.setValueId(soapModel.getValueId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setTableId(soapModel.getTableId());
    model.setColumnId(soapModel.getColumnId());
    model.setRowId(soapModel.getRowId());
    model.setClassNameId(soapModel.getClassNameId());
    model.setClassPK(soapModel.getClassPK());
    model.setData(soapModel.getData());

    return model;
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (!(obj instanceof ExpandoValue)) {
      return false;
    }

    ExpandoValue expandoValue = (ExpandoValue) obj;

    long primaryKey = expandoValue.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }

    ExpandoValue expandoValue = null;

    try {
      expandoValue = (ExpandoValue) obj;
    } catch (ClassCastException cce) {
      return false;
    }

    long pk = expandoValue.getPrimaryKey();

    if (getPrimaryKey() == pk) {
      return true;
    } else {
      return false;
    }
  }
Esempio n. 5
0
  protected void updateMPExpandoColumns(long companyId) throws Exception {
    ExpandoTable expandoTable = null;

    try {
      expandoTable = ExpandoTableLocalServiceUtil.getTable(companyId, User.class.getName(), "MP");
    } catch (NoSuchTableException nste) {
      return;
    }

    ExpandoColumn oldExpandoColumn =
        ExpandoColumnLocalServiceUtil.getColumn(
            companyId, User.class.getName(), expandoTable.getName(), "client-id");

    if (oldExpandoColumn == null) {
      return;
    }

    ExpandoColumn newExpandoColumn =
        ExpandoColumnLocalServiceUtil.getColumn(
            companyId, User.class.getName(), expandoTable.getName(), "clientId");

    if (newExpandoColumn == null) {
      newExpandoColumn =
          ExpandoColumnLocalServiceUtil.updateColumn(
              oldExpandoColumn.getColumnId(), "clientId", ExpandoColumnConstants.STRING);
    }

    List<ExpandoValue> expandoValues =
        ExpandoValueLocalServiceUtil.getColumnValues(
            oldExpandoColumn.getColumnId(), QueryUtil.ALL_POS, QueryUtil.ALL_POS);

    for (ExpandoValue expandoValue : expandoValues) {
      ExpandoValueLocalServiceUtil.addValue(
          expandoValue.getCompanyId(), User.class.getName(),
          expandoTable.getName(), newExpandoColumn.getName(),
          expandoValue.getClassPK(), expandoValue.getString());
    }

    ExpandoColumnLocalServiceUtil.deleteColumn(oldExpandoColumn.getColumnId());
  }
  public int compareTo(ExpandoValue expandoValue) {
    int value = 0;

    if (getTableId() < expandoValue.getTableId()) {
      value = -1;
    } else if (getTableId() > expandoValue.getTableId()) {
      value = 1;
    } else {
      value = 0;
    }

    if (value != 0) {
      return value;
    }

    if (getRowId() < expandoValue.getRowId()) {
      value = -1;
    } else if (getRowId() > expandoValue.getRowId()) {
      value = 1;
    } else {
      value = 0;
    }

    if (value != 0) {
      return value;
    }

    if (getColumnId() < expandoValue.getColumnId()) {
      value = -1;
    } else if (getColumnId() > expandoValue.getColumnId()) {
      value = 1;
    } else {
      value = 0;
    }

    if (value != 0) {
      return value;
    }

    return 0;
  }