Package com.sourcetap.sfa.ui

Source Code of com.sourcetap.sfa.ui.UIAttribute

/*
*
* Copyright (c) 2004 SourceTap - www.sourcetap.com
*
*  The contents of this file are subject to the SourceTap Public License
* ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sourcetap.com/license.htm
* Software distributed under the License is distributed on an  "AS IS"  basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
*/

package com.sourcetap.sfa.ui;

import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;
import org.ofbiz.base.util.UtilTimer;

import java.util.List;


/**
* DOCUMENT ME!
*
*/
public class UIAttribute {
    private static final boolean DEBUG = false;
    private static final boolean TIMER = false;
    protected String attributeId = "";
    protected String entityId = "";
    protected String attributeName = "";
    protected String description = "";
    protected String columnName = "";
    protected String displayObjectId = "";
    protected boolean isMandatory = false;
    protected boolean isReadOnly = false;
    protected boolean isVisible = false;
    protected boolean isExtension = false;
    protected boolean isSearchable = false;
    protected int displayOrder = 0;
    protected String displayLabel = "";
    protected int maxLength = 0;
    protected int displayLength = 0;
    protected int colSpan = 0;
    protected int rowSpan = 0;
    protected boolean startOnNewRow = false;
    protected boolean isPk = false;
    protected UIEntity uiEntity = null;
    protected GenericValue genericValue = null;

    public UIAttribute(GenericValue uiAttributeGV, GenericDelegator delegator,
        UIEntity uiEntity) throws GenericEntityException {
        initialize(uiAttributeGV, delegator);
        setUiEntity(uiEntity);

        // Find out if this is a primary key field of the entity.
        if (uiEntity.getPrimaryKeyFieldNames().contains(getAttributeName())) {
            setIsPk(true);
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @param attributeId_
     */
    public void setAttributeId(String attributeId_) {
        attributeId = (attributeId_ == null) ? "" : attributeId_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getAttributeId() {
        return attributeId;
    }

    /**
     * DOCUMENT ME!
     *
     * @param entityId_
     */
    public void setEntityId(String entityId_) {
        entityId = (entityId_ == null) ? "" : entityId_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getEntityId() {
        return entityId;
    }

    /**
     * DOCUMENT ME!
     *
     * @param attributeName_
     */
    public void setAttributeName(String attributeName_) {
        attributeName = (attributeName_ == null) ? "" : attributeName_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getAttributeName() {
        return attributeName;
    }

    /**
     * DOCUMENT ME!
     *
     * @param description_
     */
    public void setDescription(String description_) {
        description = (description_ == null) ? "" : description_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getDescription() {
        return description;
    }

    /**
     * DOCUMENT ME!
     *
     * @param columnName_
     */
    public void setColumnName(String columnName_) {
        columnName = columnName_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getColumnName() {
        return columnName;
    }

    /**
     * DOCUMENT ME!
     *
     * @param displayObjectId_
     */
    public void setDisplayObjectId(String displayObjectId_) {
        displayObjectId = (displayObjectId_ == null) ? "" : displayObjectId_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getDisplayObjectId() {
        return displayObjectId;
    }

    /**
     * DOCUMENT ME!
     *
     * @param maxLength_
     */
    public void setMaxLength(int maxLength_) {
        maxLength = maxLength_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param maxLength_
     */
    public void setMaxLength(String maxLength_) {
        maxLength = (maxLength_ == null) ? 0
                                         : Integer.valueOf(maxLength_).intValue();
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public int getMaxLength() {
        return maxLength;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isMandatory_
     */
    public void setIsMandatory(boolean isMandatory_) {
        isMandatory = isMandatory_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isMandatory_
     */
    public void setIsMandatory(String isMandatory_) {
        if ((isMandatory_ == null) || isMandatory_.equals("") ||
                isMandatory_.equalsIgnoreCase("N")) {
            isMandatory = false;
        } else {
            isMandatory = true;
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public boolean getIsMandatory() {
        return isMandatory;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isReadOnly_
     */
    public void setIsReadOnly(boolean isReadOnly_) {
        isReadOnly = isReadOnly_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isReadOnly_
     */
    public void setIsReadOnly(String isReadOnly_) {
        if ((isReadOnly_ == null) || isReadOnly_.equals("") ||
                isReadOnly_.equalsIgnoreCase("N")) {
            isReadOnly = false;
        } else {
            isReadOnly = true;
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public boolean getIsReadOnly() {
        return isReadOnly;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isVisible_
     */
    public void setIsVisible(boolean isVisible_) {
        isVisible = isVisible_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isVisible_
     */
    public void setIsVisible(String isVisible_) {
        if ((isVisible_ == null) || isVisible_.equals("") ||
                isVisible_.equalsIgnoreCase("N")) {
            isVisible = false;
        } else {
            isVisible = true;
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public boolean getIsVisible() {
        return isVisible;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isExtension_
     */
    public void setIsExtension(boolean isExtension_) {
        isExtension = isExtension_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isExtension_
     */
    public void setIsExtension(String isExtension_) {
        if ((isExtension_ == null) || isExtension_.equals("") ||
                isExtension_.equalsIgnoreCase("N")) {
            isExtension = false;
        } else {
            isExtension = true;
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public boolean getIsExtension() {
        return isExtension;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isSearchable_
     */
    public void setIsSearchable(boolean isSearchable_) {
        isSearchable = isSearchable_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param isSearchable_
     */
    public void setIsSearchable(String isSearchable_) {
        if ((isSearchable_ == null) || isSearchable_.equals("") ||
                isSearchable_.equalsIgnoreCase("N")) {
            isSearchable = false;
        } else {
            isSearchable = true;
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public boolean getIsSearchable() {
        return isSearchable;
    }

    /**
     * DOCUMENT ME!
     *
     * @param displayOrder_
     */
    public void setDisplayOrder(int displayOrder_) {
        displayOrder = displayOrder_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param displayOrder_
     */
    public void setDisplayOrder(String displayOrder_) {
        displayOrder = (displayOrder_ == null) ? 0
                                               : Integer.valueOf(displayOrder_)
                                                        .intValue();
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public int getDisplayOrder() {
        return displayOrder;
    }

    /**
     * DOCUMENT ME!
     *
     * @param displayLabel_
     */
    public void setDisplayLabel(String displayLabel_) {
        displayLabel = (displayLabel_ == null) ? "" : displayLabel_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getDisplayLabel() {
        return displayLabel;
    }

    /**
     * DOCUMENT ME!
     *
     * @param displayLength_
     */
    public void setDisplayLength(int displayLength_) {
        displayLength = displayLength_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param displayLength_
     */
    public void setDisplayLength(String displayLength_) {
        displayLength = (displayLength_ == null) ? 0
                                                 : Integer.valueOf(displayLength_)
                                                          .intValue();
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public int getDisplayLength() {
        return displayLength;
    }

    /**
     * DOCUMENT ME!
     *
     * @param colSpan_
     */
    public void setColSpan(int colSpan_) {
        colSpan = colSpan_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param colSpan_
     */
    public void setColSpan(String colSpan_) {
        colSpan = (colSpan_ == null) ? 0 : Integer.valueOf(colSpan_).intValue();
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public int getColSpan() {
        return colSpan;
    }

    /**
     * DOCUMENT ME!
     *
     * @param rowSpan_
     */
    public void setRowSpan(int rowSpan_) {
        rowSpan = rowSpan_;
    }

    /**
     * DOCUMENT ME!
     *
     * @param rowSpan_
     */
    public void setRowSpan(String rowSpan_) {
        rowSpan = (rowSpan_ == null) ? 0 : Integer.valueOf(rowSpan_).intValue();
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public int getRowSpan() {
        return rowSpan;
    }

  public void setStartOnNewRow(boolean startOnNewRow_) {
    startOnNewRow = startOnNewRow_;
  }

  /**
   * DOCUMENT ME!
   *
   * @param startOnNewRow_
   */
  public void setStartOnNewRow(String startOnNewRow_) {
    startOnNewRow = (startOnNewRow_ == null) ? false
                       : startOnNewRow_.toUpperCase()
                               .equals("Y");
  }

  /**
   * DOCUMENT ME!
   *
   * @return
   */
  public boolean getStartOnNewRow() {
    return startOnNewRow;
  }

    /**
     * DOCUMENT ME!
     *
     * @param isPk_
     */
    public void setIsPk(boolean isPk_) {
        isPk = isPk_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public boolean getIsPk() {
        return isPk;
    }

    /**
     * DOCUMENT ME!
     *
     * @param uiEntity_
     */
    public void setUiEntity(UIEntity uiEntity_) {
        uiEntity = uiEntity_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public UIEntity getUiEntity() {
        return uiEntity;
    }

    /**
     * DOCUMENT ME!
     *
     * @param genericValue_
     */
    public void setGenericValue(GenericValue genericValue_) {
        genericValue = genericValue_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public GenericValue getGenericValue() {
        return genericValue;
    }

    //  public UIAttribute(GenericValue uiAttributeGV, GenericDelegator delegator) throws GenericEntityException {
    //    initialize(uiAttributeGV, delegator);
    //  }
    public void initialize(GenericValue uiAttributeGV,
        GenericDelegator delegator) throws GenericEntityException {
        UtilTimer timer = new UtilTimer();

        if (TIMER) {
            timer.timerString(6, "[UIAttribute.initialize] Start");
        }

        setAttributeId(uiAttributeGV.getString("attributeId"));
        setEntityId(uiAttributeGV.getString("entityId"));
        setAttributeName(uiAttributeGV.getString("attributeName"));
        setDescription(uiAttributeGV.getString("description"));
        setColumnName(uiAttributeGV.getString("columnName"));
        setDisplayObjectId(uiAttributeGV.getString("displayObjectId"));
        setIsMandatory(uiAttributeGV.getString("isMandatory"));
        setIsReadOnly(uiAttributeGV.getString("isReadOnly"));
        setIsVisible(uiAttributeGV.getString("isVisible"));
        setIsExtension(uiAttributeGV.getString("isExtension"));
        setIsSearchable(uiAttributeGV.getString("isSearchable"));
        setDisplayLabel(uiAttributeGV.getString("displayLabel"));
        setDisplayOrder(uiAttributeGV.getString("displayOrder"));
        setMaxLength(uiAttributeGV.getString("maxLength"));
        setDisplayLength(uiAttributeGV.getString("displayLength"));
        setColSpan(uiAttributeGV.getString("colSpan"));
        setRowSpan(uiAttributeGV.getString("rowSpan"));
        setStartOnNewRow(uiAttributeGV.getString("startOnNewRow"));

        setGenericValue(uiAttributeGV);

        if (TIMER) {
            timer.timerString(6, "[UIAttribute.initialize] End");
        }
    }
}
TOP

Related Classes of com.sourcetap.sfa.ui.UIAttribute

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.