001: /*
002: * $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPersonalizer/Subsystems/Admin/Sources/es/udc/mypersonalizer/admin/http/controller/actions/propertyeditor/UpdateSimplePropertyAction.java,v 1.1.1.1 2004/03/25 12:08:38 fbellas Exp $
003: * $Revision: 1.1.1.1 $
004: * $Date: 2004/03/25 12:08:38 $
005: *
006: * =============================================================================
007: *
008: * Copyright (c) 2003, The MyPersonalizer Development Group
009: * (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at
010: * University Of A Coruna
011: * All rights reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions are met:
015: *
016: * - Redistributions of source code must retain the above copyright notice,
017: * this list of conditions and the following disclaimer.
018: *
019: * - Redistributions in binary form must reproduce the above copyright notice,
020: * this list of conditions and the following disclaimer in the documentation
021: * and/or other materials provided with the distribution.
022: *
023: * - Neither the name of the University Of A Coruna nor the names of its
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
028: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
029: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
030: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
031: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
032: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
033: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
034: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
035: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
036: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
037: * POSSIBILITY OF SUCH DAMAGE.
038: *
039: */
040:
041: package es.udc.mypersonalizer.admin.http.controller.actions.propertyeditor;
042:
043: import java.util.Collection;
044: import java.util.ArrayList;
045:
046: import javax.servlet.http.HttpServletRequest;
047:
048: import es.udc.mypersonalizer.kernel.model.metainfo.MetaProperty;
049: import es.udc.mypersonalizer.kernel.model.metainfo.MetaSimpleProperty;
050: import es.udc.mypersonalizer.kernel.model.properties.Property;
051:
052: import es.udc.mypersonalizer.admin.http.controller.actions.propertyeditor.util.PropertyEditorHelper;
053: import es.udc.mypersonalizer.admin.http.view.viewobjects.propertyeditor.ViewProperty;
054:
055: /**
056: * Implements the Template Method pattern hook method to create a Collection
057: * of one <code>ViewProperty</code> object with information about a
058: * <code>SimpleProperty/code>.
059: *
060: * @author Abel Iago Toral Quiroga
061: * @since 1.0
062: */
063:
064: public class UpdateSimplePropertyAction extends
065: AbstractUpdatePropertyAction {
066:
067: protected Collection getViewPropertiesList(
068: HttpServletRequest request, Property currentSimpleProperty,
069: MetaProperty currentMetaProperty, int valueIndex)
070: throws Exception {
071:
072: String valueLabel = getResources(request).getMessage(
073: "PropertyEditor.CommonLabels.value");
074:
075: /* Collection with property information */
076: Collection viewPropertyValues = new ArrayList();
077:
078: /* Get property single-value as String if possible*/
079: String propertySingleValue = null;
080: String[] simplePropertyValuesAsString = currentSimpleProperty
081: .getValuesAsString();
082:
083: if (simplePropertyValuesAsString.length > valueIndex) {
084: propertySingleValue = simplePropertyValuesAsString[valueIndex];
085: }
086:
087: /* Add property information to list */
088: /* As this is a SimpleProperty, list will have only this element*/
089: MetaSimpleProperty currentMetaSimpleProperty = (MetaSimpleProperty) currentMetaProperty;
090:
091: boolean isBoolean = currentMetaSimpleProperty.getJavaType()
092: .equals(Boolean.TRUE.getClass());
093:
094: ViewProperty viewProperty = new ViewProperty(valueLabel,
095: propertySingleValue, false, false, isBoolean);
096:
097: Collection viewPropertiesList = new ArrayList();
098: viewPropertiesList.add(viewProperty);
099:
100: return PropertyEditorHelper
101: .sortViewProperties(viewPropertiesList);
102: }
103: }
|