Package com.sourcetap.sfa.ui

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

/*
*
* 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.base.util.UtilTimer;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.entity.GenericEntityException;
import org.ofbiz.entity.GenericValue;


/**
* DOCUMENT ME!
*
*/
public class UIFieldInfo {
  public static final String module = UIFieldInfo.class.getName();
    private static final boolean TIMER = false;
    protected static final int DEFAULT_WIDTH = 100;
    protected String sectionId = "";
    protected String partyId = "";
    protected String attributeId = "";
    protected String displayLabel = "";
    protected int displayLength = DEFAULT_WIDTH;
    protected int maxLength = DEFAULT_WIDTH;

    //  protected boolean isUpdateable = false;
    protected boolean isReadOnly = false;
    protected boolean isVisible = true;
    protected boolean isMandatory = false;
    protected boolean isSearchable = false;
    protected int displayOrder = 0;
    protected String displayObjectId = "";
    protected int rowSpan = 0;
    protected int colSpan = 0;
    protected boolean startOnNewRow = false;

    //  protected UIScreen uiScreen = null;
    //  protected UIScreenSection uiScreenSection = null;
    //  protected UIEntity uiEntity = null;
    protected UIScreenSectionEntity uiScreenSectionEntity = null;
    protected UIAttribute uiAttribute = null;
    protected UIDisplayObject uiDisplayObject = null;

    public UIFieldInfo(GenericValue uiScreenSectionInfoGV,
        GenericDelegator delegator, UICache uiCache)
        throws GenericEntityException {
        UtilTimer timer = new UtilTimer();

        if (TIMER) {
            timer.timerString(1, "[UIFieldInfo.UIFieldInfo] Start");
        }

        setSectionId(uiScreenSectionInfoGV.getString("sectionId"));
        setPartyId(uiScreenSectionInfoGV.getString("partyId"));
        setAttributeId(uiScreenSectionInfoGV.getString("attributeId"));
        setDisplayObjectId(uiScreenSectionInfoGV.getString("displayObjectId"));
        setMaxLength(uiScreenSectionInfoGV.getString("maxLength"));
        setIsMandatory(uiScreenSectionInfoGV.getString("isMandatory"));
        setIsReadOnly(uiScreenSectionInfoGV.getString("isReadOnly"));
        setIsVisible(uiScreenSectionInfoGV.getString("isVisible"));
        setIsSearchable(uiScreenSectionInfoGV.getString("isSearchable"));
        setDisplayOrder(uiScreenSectionInfoGV.getString("displayOrder"));
        setDisplayLabel(uiScreenSectionInfoGV.getString("displayLabel"));
        setDisplayLength(uiScreenSectionInfoGV.getString("displayLength"));
        setColSpan(uiScreenSectionInfoGV.getString("colSpan"));
        setRowSpan(uiScreenSectionInfoGV.getString("rowSpan"));
        setStartOnNewRow(uiScreenSectionInfoGV.getString("startOnNewRow"));

        // Get the UIDisplayObject.
        if (TIMER) {
            timer.timerString(2,
                "[UIFieldInfo.UIFieldInfo] Looking for UIDisplayObject in cache.");
        }

        String displayObjectId = getDisplayObjectId();
        UIDisplayObject uiDisplayObject = uiCache.getUiDisplayObject(displayObjectId);

        if (uiDisplayObject == null) {
            if (TIMER) {
                timer.timerString(2,
                    "[UIFieldInfo.UIFieldInfo] UIDisplayObject not found in cache. Creating a new one.");
            }

            uiDisplayObject = new UIDisplayObject(displayObjectId, delegator);
            uiCache.putUiDisplayObject(displayObjectId, uiDisplayObject);
        } else {
            if (TIMER) {
                timer.timerString(2,
                    "[UIFieldInfo.UIFieldInfo] Found UIDisplayObject in cache.");
            }
        }

        setUiDisplayObject(uiDisplayObject);

        if (TIMER) {
            timer.timerString(2, "[UIFieldInfo.UIFieldInfo] Got UIDisplayObject");
        }

        // Get the UIAttribute object.
        if (TIMER) {
            timer.timerString(2,
                "[UIFieldInfo.UIFieldInfo] Looking for UIAttribute " +
                attributeId + " in cache.");
        }

        String attributeId = getAttributeId();
        UIAttribute uiAttribute = uiCache.getUiAttribute(attributeId);

        if (uiAttribute == null) {
            throw new GenericEntityException("Attribute " + attributeId +
                " does not appear in any of the entities for this screen section.");
        } else {
            if (TIMER) {
                timer.timerString(2,
                    "[UIFieldInfo.UIFieldInfo] Found UIAttribute in cache.");
            }
        }

        setUiAttribute(uiAttribute);

        if (TIMER) {
            timer.timerString(2, "[UIFieldInfo.UIFieldInfo] Got UIAttribute");
        }

        // Get the UIScreenSectionEntity object.
        if (TIMER) {
            timer.timerString(2,
                "[UIFieldInfo.UIFieldInfo] Looking for UIScreenSectionEntity in cache.");
        }

        String sectionId = getSectionId();
        String entityId = getUiAttribute().getEntityId();
        UIScreenSectionEntity uiScreenSectionEntity = uiCache.getUiScreenSectionEntity(sectionId,
                entityId);

        if (uiScreenSectionEntity == null) {

            throw new GenericEntityException("Attribute '" +
                getUiAttribute().getAttributeName() +
                "' does not appear in any of the entities for this screen section.");
        } else {
            if (TIMER) {
                timer.timerString(2,
                    "[UIFieldInfo.UIFieldInfo] Found UIScreenSectionEntity in cache.");
            }
        }

        setUiScreenSectionEntity(uiScreenSectionEntity);

        if (TIMER) {
            timer.timerString(2,
                "[UIFieldInfo.UIFieldInfo] Got UIScreenSectionEntity");
        }

        if (TIMER) {
            timer.timerString(1, "[UIFieldInfo.UIFieldInfo] End");
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @param sectionId_
     */
    public void setSectionId(String sectionId_) {
        sectionId = (sectionId_ == null) ? "" : sectionId_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getSectionId() {
        return sectionId;
    }

    /**
     * DOCUMENT ME!
     *
     * @param partyId_
     */
    public void setPartyId(String partyId_) {
        partyId = (partyId_ == null) ? "" : partyId_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getPartyId() {
        return partyId;
    }

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

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

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

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public String getDisplayLabel() {
        if (displayLabel == null) {
            return getUiAttribute().getAttributeName();
        } else {
            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 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 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 isVisible_
     */
    public void setIsVisible(boolean isVisible_) {
        isVisible = isVisible_;
    }

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

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

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

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

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

    //  public void setIsUpdateable(boolean isUpdateable_) {
    //    isUpdateable = isUpdateable_;
    //  }
    //  public void setIsUpdateable(String isUpdateable_) {
    //    isUpdateable = isUpdateable_==null ? false : isUpdateable_.toUpperCase().equals("Y");
    //  }
    //  public boolean getIsUpdateable() {
    //    return isUpdateable;
    //  }
    public void setIsMandatory(boolean isMandatory_) {
        isMandatory = isMandatory_;
    }

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

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

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

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

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

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

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

    /**
     * DOCUMENT ME!
     *
     * @param uiDisplayObject_
     */
    public void setUiDisplayObject(UIDisplayObject uiDisplayObject_) {
        uiDisplayObject = uiDisplayObject_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public UIDisplayObject getUiDisplayObject() {
        return uiDisplayObject;
    }

    /**
     * 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;
    }

    /**
     * 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;
    }

  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;
  }


    //  public void setUiScreen(UIScreen uiScreen_) {
    //    uiScreen = uiScreen_;
    //  }
    //  public UIScreen getUiScreen() {
    //    return uiScreen;
    //  }
    //  public void setUiScreenSection(UIScreenSection uiScreenSection_) {
    //    uiScreenSection = uiScreenSection_;
    //  }
    //  public UIScreenSection getUiScreenSection() {
    //    return uiScreenSection;
    //  }
    public void setUiAttribute(UIAttribute uiAttribute_) {
        uiAttribute = uiAttribute_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public UIAttribute getUiAttribute() {
        return uiAttribute;
    }

    //  public void setUiEntity(UIEntity uiEntity_) {
    //    uiEntity = uiEntity_;
    //  }
    //  public UIEntity getUiEntity() {
    //    return uiEntity;
    //  }
    public void setUiScreenSectionEntity(
        UIScreenSectionEntity uiScreenSectionEntity_) {
        uiScreenSectionEntity = uiScreenSectionEntity_;
    }

    /**
     * DOCUMENT ME!
     *
     * @return
     */
    public UIScreenSectionEntity getUiScreenSectionEntity() {
        return uiScreenSectionEntity;
    }
}
TOP

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

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.