Search in sources :

Example 6 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class AMPropertySheet method setAttributeValues.

/**
     * Set values to model of a <code>CCPropertySheet</code> component.
     *          
     * @param attributeValues Map of attribute name to values.
     */
public void setAttributeValues(Map attributeValues, AMModel amModel) {
    AMPropertySheetModel model = (AMPropertySheetModel) getModel();
    ViewBean parent = getParentViewBean();
    for (Iterator iter = attributeValues.keySet().iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        // different attribute types set different types of data
        // get Object from the values and convert as needed.
        Object values = attributeValues.get(name);
        View view = null;
        try {
            view = parent.getChild(name);
        } catch (IllegalArgumentException e) {
            // skip this attribute. its not defined in the property sheet
            continue;
        }
        if (view != null) {
            if (setValuesToMultipleChoices(parent, name, values, amModel, model) || setValuesToAddRemove(view, name, values, amModel, model) || setValuesToEditableList(view, name, values, amModel, model) || setValuesToOrderedList(view, name, values, amModel, model) || setValuesToUnOrderedList(view, name, values, amModel, model) || setValuesToMapList(view, name, values, amModel, model) || setValuesToDateTime(view, name, values, amModel, model) || setValuesToSelect(view, name, values, amModel, model)) {
            // do nothing.
            } else {
                // all other element types should be passing a set
                if (Set.class.isInstance(values)) {
                    if (model.isChildSupported(name + PropertyTemplate.PWD_CONFIRM_SUFFIX)) {
                        model.setValues(name + PropertyTemplate.PWD_CONFIRM_SUFFIX, ((Set) values).toArray(), amModel);
                    }
                    if ((values != null) && !((Set) values).isEmpty() && model.isChildSupported(name + PropertyTemplate.PASSWORD_VALUE_TAG)) {
                        model.setValue(name, PASSWORD_MASK);
                    } else {
                        model.setValues(name, ((Set) values).toArray(), amModel);
                    }
                }
            }
        }
    }
}
Also used : AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) Iterator(java.util.Iterator) ViewBean(com.iplanet.jato.view.ViewBean) View(com.iplanet.jato.view.View) ContainerView(com.iplanet.jato.view.ContainerView)

Example 7 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class AMPropertySheet method init.

public void init() {
    ViewBean parent = getParentViewBean();
    AMPropertySheetModel model = (AMPropertySheetModel) getModel();
    Map radioComponents = model.getRadioDefaultValues();
    if ((radioComponents != null) && !radioComponents.isEmpty()) {
        for (Iterator i = radioComponents.keySet().iterator(); i.hasNext(); ) {
            String name = (String) i.next();
            CCRadioButton rb = (CCRadioButton) parent.getChild(name);
            Object value = rb.getValue();
            if (value == null) {
                rb.setValue(radioComponents.get(name));
            }
        }
    }
}
Also used : CCRadioButton(com.sun.web.ui.view.html.CCRadioButton) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) Iterator(java.util.Iterator) ViewBean(com.iplanet.jato.view.ViewBean) HashMap(java.util.HashMap) Map(java.util.Map)

Example 8 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class AMServiceProfileViewBeanBase method createPropertyModel.

protected void createPropertyModel() {
    AMServiceProfileModel model = (AMServiceProfileModel) getModel();
    if (model != null) {
        try {
            propertySheetModel = new AMPropertySheetModel(getPropertySheetXML(model));
            propertySheetModel.clear();
        } catch (AMConsoleException e) {
            setInlineAlertMessage(CCAlert.TYPE_ERROR, "message.error", e.getMessage());
        }
    }
}
Also used : AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) AMServiceProfileModel(com.sun.identity.console.base.model.AMServiceProfileModel)

Example 9 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class AMPropertySheet method getAttributeValues.

/**
     * Returns a map of attribute name to values.
     *
     * @param attrNames Set of attribute names to retrieve.
     * @return map of attribute name to values.
     * @throws ModelControlException if cannot get model of property sheet.
     * @throws AMConsoleException if password and confirm password values do
     *         not match.
     */
public Map getAttributeValues(Collection attrNames) throws ModelControlException, AMConsoleException {
    restoreStateData(attrNames);
    AMPropertySheetModel model = (AMPropertySheetModel) getModel();
    Map attrValues = new HashMap(attrNames.size() * 2);
    Map multipleChoiceValues = getMultipleChoiceValues(model);
    for (Iterator iter = attrNames.iterator(); iter.hasNext(); ) {
        String name = (String) iter.next();
        Object childModel = model.getModel(name);
        Set values = null;
        if (CCAddRemoveModel.class.isInstance(childModel)) {
            values = getValues(((CCAddRemoveModel) childModel).getSelectedOptionList());
        } else if (CCUnOrderedListModel.class.isInstance(childModel)) {
            values = getListValues(((CCUnOrderedListModel) childModel).getOptionList());
            if ((values == null) || values.isEmpty()) {
                values = new HashSet(2);
                values.add("[0]=");
            }
        } else if (CCMapListModel.class.isInstance(childModel)) {
            values = getValues(((CCMapListModel) childModel).getOptionList());
            if ((values == null) || values.isEmpty()) {
                values = new HashSet(2);
                values.add("[]=");
            }
        } else if (CCEditableListModel.class.isInstance(childModel)) {
            values = getValues(((CCEditableListModel) childModel).getOptionList());
        } else if (CCOrderedListModel.class.isInstance(childModel)) {
            values = getListValues(((CCOrderedListModel) childModel).getSelectedOptionList());
            if ((values == null) || values.isEmpty()) {
                values = new HashSet(2);
                values.add("[0]=");
            }
        } else if (model.isChildSupported(name + PropertyTemplate.PWD_CONFIRM_SUFFIX)) {
            String pwd = (String) model.getValue(name);
            String confirmPwd = (String) model.getValue(name + PropertyTemplate.PWD_CONFIRM_SUFFIX);
            if (pwd.equals(confirmPwd)) {
                if (!pwd.equals(AMPropertySheetModel.passwordRandom)) {
                    values = new HashSet(2);
                    values.add(pwd);
                }
            } else {
                throw new AMConsoleException("password-mismatched");
            }
        } else {
            values = (Set) multipleChoiceValues.get(name);
            if (values == null) {
                values = AMAdminUtils.toSetIgnoreEmpty(model.getValues(name));
            }
        }
        if (values != null) {
            attrValues.put(name, values);
        }
    }
    return attrValues;
}
Also used : TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) OrderedSet(com.sun.identity.shared.datastruct.OrderedSet) CCAddRemoveModel(com.sun.web.ui.model.CCAddRemoveModel) HashMap(java.util.HashMap) CCMapListModel(com.sun.identity.console.ui.model.CCMapListModel) AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel) CCOrderedListModel(com.sun.identity.console.ui.model.CCOrderedListModel) Iterator(java.util.Iterator) CCUnOrderedListModel(com.sun.identity.console.ui.model.CCUnOrderedListModel) CCEditableListModel(com.sun.web.ui.model.CCEditableListModel) AMConsoleException(com.sun.identity.console.base.model.AMConsoleException) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Example 10 with AMPropertySheetModel

use of com.sun.identity.console.base.model.AMPropertySheetModel in project OpenAM by OpenRock.

the class ServicesSelectViewBean method createPropertyModel.

private void createPropertyModel() {
    propertySheetModel = new AMPropertySheetModel(getClass().getClassLoader().getResourceAsStream("com/sun/identity/console/propertyEntityServicesSelect.xml"));
    propertySheetModel.clear();
}
Also used : AMPropertySheetModel(com.sun.identity.console.base.model.AMPropertySheetModel)

Aggregations

AMPropertySheetModel (com.sun.identity.console.base.model.AMPropertySheetModel)146 DelegationConfig (com.sun.identity.console.delegation.model.DelegationConfig)32 AMConsoleException (com.sun.identity.console.base.model.AMConsoleException)16 CCAddRemoveModel (com.sun.web.ui.model.CCAddRemoveModel)9 InputStream (java.io.InputStream)8 HashSet (java.util.HashSet)7 Set (java.util.Set)7 Iterator (java.util.Iterator)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 CCEditableListModel (com.sun.web.ui.model.CCEditableListModel)3 List (java.util.List)3 ViewBean (com.iplanet.jato.view.ViewBean)2 AgentsModel (com.sun.identity.console.agentconfig.model.AgentsModel)2 AbstractAuditModel (com.sun.identity.console.audit.model.AbstractAuditModel)2 EntitiesModel (com.sun.identity.console.idm.model.EntitiesModel)2 RMRealmModel (com.sun.identity.console.realm.model.RMRealmModel)2 SubConfigModel (com.sun.identity.console.service.model.SubConfigModel)2 CCOrderedListModel (com.sun.identity.console.ui.model.CCOrderedListModel)2