You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2006/10/15 15:33:54 UTC

svn commit: r464192 [3/4] - in /myfaces/tomahawk/trunk/sandbox15: core/ core/src/main/java/org/ core/src/main/java/org/apache/ core/src/main/java/org/apache/myfaces/ core/src/main/java/org/apache/myfaces/custom/ core/src/main/java/org/apache/myfaces/cu...

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ObjectSerializationConverter.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ObjectSerializationConverter.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ObjectSerializationConverter.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ObjectSerializationConverter.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.lib;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.convert.ConverterException;
+
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.myfaces.custom.dynaForm.lib.NullObject;
+
+/**
+ * This converter will be used to e.g. render a selection menu. <br />
+ * It is responsible to convert a object to a string-identifier representation with which it is possible to
+ * recreate the object again - aka serialization 
+ */
+public class ObjectSerializationConverter implements Converter
+{
+	public static final NullObject SELECT_NULL_OBJECT = new NullObject();
+	
+	public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException
+	{
+		if (value == null || value.length() < 1 || SELECT_NULL_OBJECT.equals(value))
+		{
+			return null;
+		}
+
+		ObjectInputStream ois = null;
+		Serializable objectIdent;
+		try
+		{
+			byte[] base64 = Base64.decodeBase64(value.getBytes("UTF-8"));
+			ois = new ObjectInputStream(new ByteArrayInputStream(base64));
+			objectIdent = (Serializable) ois.readObject();
+			ois.close();
+		}
+		catch (IOException e)
+		{
+			throw new ConverterException(e);
+		}
+		catch (ClassNotFoundException e)
+		{
+			throw new ConverterException(e);
+		}
+		finally
+		{
+			if (ois != null)
+			{
+				try
+				{
+					ois.close();
+				}
+				catch (IOException e)
+				{
+					// consume exception, should never happen
+				}
+			}
+		}
+		
+		return objectIdent;
+	}
+
+	public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException
+	{
+		if (value == null || SELECT_NULL_OBJECT.equals(value))
+		{
+			return "";
+		}
+		
+		ObjectOutputStream oos = null;
+		try
+		{
+			ByteArrayOutputStream baos = new ByteArrayOutputStream(1024); 
+			oos = new ObjectOutputStream(baos);
+			oos.writeObject(value);
+			byte[] base64 = Base64.encodeBase64(baos.toByteArray());
+			String objectString = new String(base64, "UTF-8");
+			return objectString;
+		}
+		catch (IOException e)
+		{
+			throw new ConverterException(e);
+		}
+		finally
+		{
+			if (oos != null)
+			{
+				try
+				{
+					oos.close();
+				}
+				catch (IOException e)
+				{
+					// consume exception, should never happen
+				}
+			}
+		}
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ObjectSerializationConverter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ObjectSerializationConverter.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ObjectSerializationConverter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/OrderDirectionEnum.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/OrderDirectionEnum.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/OrderDirectionEnum.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/OrderDirectionEnum.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.lib;
+
+public enum OrderDirectionEnum
+{
+	asc,
+	desc
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/OrderDirectionEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/OrderDirectionEnum.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/OrderDirectionEnum.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionSourceEnum.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionSourceEnum.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionSourceEnum.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionSourceEnum.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.lib;
+
+public enum SelectionSourceEnum
+{
+	manual,
+	relation,
+	distinct
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionSourceEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionSourceEnum.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionSourceEnum.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionTypeEnum.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionTypeEnum.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionTypeEnum.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionTypeEnum.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.lib;
+
+public enum SelectionTypeEnum
+{
+	none,
+	one,
+	many
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionTypeEnum.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionTypeEnum.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/SelectionTypeEnum.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ViewType.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ViewType.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ViewType.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ViewType.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.lib;
+
+public enum ViewType
+{
+	FORM,
+	LIST
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ViewType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ViewType.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/lib/ViewType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Extractor.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Extractor.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Extractor.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Extractor.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata;
+
+/**
+ * The metadata extractor interface 
+ */
+public interface Extractor
+{
+	/**
+	 * get the metadata for the given entity
+	 */
+	public void getMetaData(MetaData metaData, Object entity);
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Extractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Extractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Extractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/FieldInterface.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/FieldInterface.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/FieldInterface.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/FieldInterface.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata;
+
+import javax.faces.component.UIComponent;
+import javax.persistence.TemporalType;
+
+import org.apache.myfaces.custom.dynaForm.guiBuilder.ComponentEnum;
+import org.apache.myfaces.custom.dynaForm.lib.SelectionSourceEnum;
+
+public interface FieldInterface
+{
+	public String getName();
+	public String getBaseName();
+	public String getExternalName();
+	public Class getType();
+	public boolean isEntityType();
+	public Boolean getDisabled();
+	public Boolean getCanRead();
+	public Boolean getCanWrite();
+	public Boolean getDisplayOnly();
+	public boolean getRequired();
+	public Selection[] getAllowedSelections();
+	public RelationType getRelationType();
+
+	/**
+	 * in case of hierarchical structures this defines if a child class should be treatened
+	 * as "embedded".<br />
+	 * <ul>
+	 * <li>Embedded: like a composite key in hibernate</li>
+	 * <li>Not Embedded: like a relation to another entity (ManyToOne)</li>
+	 * </ul>
+	 * This is not a metadata for the field itself, but for the context in which this field
+	 * (or its entity) will be used
+	 */
+	public boolean isEmbedded();
+
+	public Integer getMaxSize();
+	public Double getMaxValue();
+	public Integer getMinSize();
+	public Integer getDisplaySize();
+	public Double getMinValue();
+	public UIComponent getWantedComponent();
+	public ComponentEnum getWantedComponentType();
+	public TemporalType getTemporalType();
+	public boolean getAllowMultipleSelections();
+	public SelectionSourceEnum getSelectionSource();
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/FieldInterface.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/FieldInterface.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/FieldInterface.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaData.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaData.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaData.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaData.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,430 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.io.Serializable;
+
+import javax.faces.component.UIComponent;
+import javax.persistence.TemporalType;
+
+import org.apache.myfaces.custom.dynaForm.guiBuilder.ComponentEnum;
+import org.apache.myfaces.custom.dynaForm.lib.SelectionSourceEnum;
+
+/**
+ * Holds all the metadata
+ */
+public class MetaData implements MetaDataInterface
+{
+	private final Set<String> requestedFields = new TreeSet<String>();
+	private final Set<String> requestedFieldParents = new TreeSet<String>();
+	private final Map<String, FieldImpl> fields = new LinkedHashMap<String, FieldImpl>();
+
+	private boolean lockFields = false;
+
+	/**
+	 * Metadata for a field
+	 */
+	public static class FieldImpl implements FieldInterface, Serializable
+	{
+		private final String name;
+		private final String baseName;
+		private String preferredExternalName;
+		private Class type = null;
+		private boolean entityType = false;
+		private Boolean canRead = null;
+		private Boolean canWrite = null;
+		private Boolean disabled = null;
+		private Boolean displayOnly = null;
+		private boolean required = false;
+		private RelationType relationType = RelationType.NONE;
+		private boolean embedded = true;
+		private Integer displaySize = null;
+		private Integer minSize = null;
+		private Integer maxSize = null;
+		private Double minValue = null;
+		private Double maxValue = null;
+		private TemporalType temporalType = null;
+
+		private Selection[] allowedSelection = null;
+		private boolean allowMultipleSelections = false;
+		private SelectionSourceEnum selectionSource = null;
+
+		private UIComponent wantedComponent = null;
+		private ComponentEnum wantedComponentType = ComponentEnum.Automatic;
+
+		protected FieldImpl(String name)
+		{
+			this.name = name;
+			int pos = name.lastIndexOf('.');
+			if (pos > -1)
+			{
+				this.baseName = name.substring(pos+1);
+			}
+			else
+			{
+				this.baseName = name;
+			}
+		}
+
+		public String getName()
+		{
+			return name;
+		}
+
+		public String getBaseName()
+		{
+			return baseName;
+		}
+
+		public String getExternalName()
+		{
+			if (getPreferredExternalName() != null)
+			{
+				return getPreferredExternalName();
+			}
+
+			return getName();
+		}
+
+		public String getPreferredExternalName()
+		{
+			return preferredExternalName;
+		}
+
+		public void setPreferredExternalName(String preferredExternalName)
+		{
+			this.preferredExternalName = preferredExternalName;
+		}
+
+		public Class getType()
+		{
+			return type;
+		}
+
+		public void setType(Class type)
+		{
+			if (this.type != null && this.type != type)
+			{
+				throw new IllegalArgumentException("" + name
+						+ ": reset with different type denied. curr:"
+						+ this.type.getName() + " new:" + type.getName());
+			}
+			this.type = type;
+		}
+
+		public Boolean getDisplayOnly()
+		{
+			return displayOnly;
+		}
+
+		public void setDisplayOnly(Boolean displayOnly)
+		{
+			this.displayOnly = displayOnly;
+		}
+
+		public boolean isCanRead()
+		{
+			return getCanRead() != null && getCanRead().booleanValue();
+		}
+
+		public void setCanRead(boolean canRead)
+		{
+			this.canRead = canRead;
+		}
+
+		public Boolean getCanRead()
+		{
+			return this.canRead;
+		}
+
+		public void setCanWrite(boolean canWrite)
+		{
+			this.canWrite = canWrite;
+		}
+
+		public Boolean getCanWrite()
+		{
+			return canWrite;
+		}
+
+		public void setDisabled(boolean disabled)
+		{
+			this.disabled = disabled;
+		}
+
+		public Boolean getDisabled()
+		{
+			return disabled;
+		}
+
+		public boolean getRequired()
+		{
+			return required;
+		}
+
+		public void setRequired(boolean nullable)
+		{
+			this.required = nullable;
+		}
+
+		public Selection[] getAllowedSelections()
+		{
+			return allowedSelection;
+		}
+
+		public void setAllowedSelections(Selection[] allowedSelections)
+		{
+			this.allowedSelection = allowedSelections;
+		}
+
+		public RelationType getRelationType()
+		{
+			return relationType;
+		}
+
+		public void setRelationType(RelationType relationType)
+		{
+			this.relationType = relationType;
+		}
+
+		public Integer getMaxSize()
+		{
+			return maxSize;
+		}
+
+		public void setMaxSize(Integer maxSize)
+		{
+			this.maxSize = maxSize;
+		}
+
+		public Double getMaxValue()
+		{
+			return maxValue;
+		}
+
+		public void setMaxValue(Double maxValue)
+		{
+			this.maxValue = maxValue;
+		}
+
+		public Integer getMinSize()
+		{
+			return minSize;
+		}
+
+		public void setMinSize(Integer minSize)
+		{
+			this.minSize = minSize;
+		}
+
+		public Double getMinValue()
+		{
+			return minValue;
+		}
+
+		public void setMinValue(Double minValue)
+		{
+			this.minValue = minValue;
+		}
+
+		public void setWantedComponent(UIComponent component)
+		{
+			this.wantedComponent = component;
+		}
+
+		public UIComponent getWantedComponent()
+		{
+			return wantedComponent;
+		}
+
+		public void setWantedComponentType(ComponentEnum componentType)
+		{
+			this.wantedComponentType = componentType;
+		}
+
+		public ComponentEnum getWantedComponentType()
+		{
+			return this.wantedComponentType;
+		}
+
+		public void setDisplaySize(int displaySize)
+		{
+			this.displaySize = displaySize;
+		}
+
+		public Integer getDisplaySize()
+		{
+			return displaySize;
+		}
+
+		public void setTemporalType(TemporalType temporalType)
+		{
+			this.temporalType = temporalType;
+		}
+
+		public TemporalType getTemporalType()
+		{
+			return temporalType;
+		}
+
+		public boolean getAllowMultipleSelections()
+		{
+			return allowMultipleSelections;
+		}
+
+		public void setAllowMultipleSelections(boolean allowMultipleSelections)
+		{
+			this.allowMultipleSelections = allowMultipleSelections;
+		}
+
+		public SelectionSourceEnum getSelectionSource()
+		{
+			return selectionSource;
+		}
+
+		public void setSelectionSource(SelectionSourceEnum selectionSource)
+		{
+			this.selectionSource = selectionSource;
+		}
+
+		public boolean isEntityType()
+		{
+			return entityType;
+		}
+
+		public void setEntityType(boolean entityType)
+		{
+			this.entityType = entityType;
+		}
+
+		public boolean isEmbedded()
+		{
+			return embedded;
+		}
+
+		public void setEmbedded(boolean embedded)
+		{
+			this.embedded = embedded;
+		}
+	}
+
+	public MetaData()
+	{
+	}
+
+	/**
+	 * should this field be processed
+	 *
+	 * @see #setLockFields(boolean)
+	 */
+	public boolean processField(String name)
+	{
+		return !lockFields || processFieldParent(name) || requestedFields.contains(name) || fields.containsKey(name);
+	}
+
+	/**
+	 * should this field be processed.
+	 *
+	 * @return true if the given name is the parent of one of the requestedFields
+	 * @see #processField(String)
+	 * @see #setLockFields(boolean)
+	 */
+	public boolean processFieldParent(String name)
+	{
+		return requestedFieldParents.contains(name);
+	}
+
+	/**
+	 * request to add this field if we reach it. eg. used to trigger traversing the object graph for
+	 * linked entities
+	 */
+	public void requestField(String name)
+	{
+ 		int currIndex = name.indexOf('.');
+		while (currIndex > -1)
+		{
+			String key = name.substring(0, currIndex);
+			if (!requestedFieldParents.contains(key))
+			{
+				requestedFieldParents.add(key);
+			}
+			currIndex = name.indexOf('.', currIndex+1);
+		}
+
+		requestedFields.add(name);
+	}
+
+	public Set<String> getRequestedFields()
+	{
+		return Collections.unmodifiableSet(requestedFields);
+	}
+
+	/**
+	 * add a new field to the metadata or return one if one already exists for
+	 * the given name
+	 */
+	public FieldImpl getOrCreateField(String name)
+	{
+		if (!processField(name))
+		{
+			throw new SecurityException("Current state do not allow to add the field: " + name);
+		}
+
+		FieldImpl field = fields.get(name);
+		if (field == null)
+		{
+			field = new FieldImpl(name);
+			fields.put(name, field);
+		}
+		return field;
+	}
+
+	public int getFieldCount()
+	{
+		return fields.size();
+	}
+
+	public Iterator<String> iterFieldNames()
+	{
+		return fields.keySet().iterator();
+	}
+
+	public FieldInterface getField(String name)
+	{
+		return fields.get(name);
+	}
+
+	public String[] getFieldNames()
+	{
+		return fields.keySet().toArray(new String[fields.size()]);
+	}
+
+	/**
+	 * if set to true this avoids any field to be newly created, only already existent fields are to be processed
+	 */
+	public boolean setLockFields(boolean lockFields)
+	{
+		boolean prev = this.lockFields;
+		this.lockFields = lockFields;
+		return prev;
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaData.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaData.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaDataInterface.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaDataInterface.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaDataInterface.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaDataInterface.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata;
+
+import java.util.Iterator;
+
+public interface MetaDataInterface
+{
+	/**
+	 * number of fields
+	 */
+	public int getFieldCount();
+
+	/**
+	 * iterate through fields
+	 */
+	public Iterator<String> iterFieldNames();
+
+	/**
+	 * get the field by name
+	 */
+	public FieldInterface getField(String name);
+
+	/**
+	 * get all fields names
+	 */
+	public String[] getFieldNames();
+}
\ No newline at end of file

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaDataInterface.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaDataInterface.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/MetaDataInterface.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/RelationType.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/RelationType.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/RelationType.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/RelationType.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata;
+
+public enum RelationType
+{
+	NONE,
+	ONE_TO_ONE,
+	ONE_TO_MANY,
+	MANY_TO_ONE,
+	MANY_TO_MANY
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/RelationType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/RelationType.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/RelationType.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Selection.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Selection.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Selection.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Selection.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata;
+
+import java.io.Serializable;
+
+/**
+ * represents a selection (e.g. for select menus)
+ */
+public class Selection implements Serializable
+{
+	private final String label;
+	private final Object value;
+
+	/**
+	 * let the gui determine how to display this value
+	 */
+	public Selection(Object value)
+	{
+		this(null, value);
+	}
+
+	/**
+	 * selection with fixed label
+	 */
+	public Selection(String label, Object value)
+	{
+		this.label = label;
+		this.value = value;
+	}
+
+	public String getLabel()
+	{
+		return label;
+	}
+
+	public Object getValue()
+	{
+		return value;
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Selection.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Selection.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/Selection.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/BcelHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/BcelHelper.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/BcelHelper.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/BcelHelper.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,171 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.ejb;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.myfaces.custom.dynaForm.lib.DynaFormException;
+
+import org.apache.bcel.Repository;
+import org.apache.bcel.classfile.JavaClass;
+import org.apache.bcel.generic.ArrayType;
+import org.apache.bcel.generic.BasicType;
+import org.apache.bcel.generic.ObjectType;
+import org.apache.bcel.generic.Type;
+
+/**
+ * Extracts fields/method of the given class using BCEL. <br />
+ * This allows us to keep the ordering.
+ */
+public class BcelHelper implements ClassHelper
+{
+	public Field[] getFields(Class clazz)
+	{
+		JavaClass javaClass = Repository.lookupClass(clazz);
+		org.apache.bcel.classfile.Field[] fields = javaClass.getFields();
+		
+		List<Field> ret = new ArrayList<Field>(fields.length);
+		for (org.apache.bcel.classfile.Field field : fields)
+		{
+			try
+			{
+				ret.add(clazz.getDeclaredField(field.getName()));
+			}
+			catch (SecurityException e)
+			{
+				throw new DynaFormException(e);
+			}
+			catch (NoSuchFieldException e)
+			{
+				throw new DynaFormException(e);
+			}
+		}
+		return ret.toArray(new Field[ret.size()]);
+	}
+
+	public Method[] getMethods(Class clazz)
+	{
+		JavaClass javaClass = Repository.lookupClass(clazz);
+		org.apache.bcel.classfile.Method[] methods = javaClass.getMethods();
+		
+		List<Method> ret = new ArrayList<Method>(methods.length);
+		for (org.apache.bcel.classfile.Method method : methods)
+		{
+			if ("<init>".equals(method.getName()))
+			{
+				continue;
+			}
+			if (!method.getName().startsWith("set") && !method.getName().startsWith("get") && !method.getName().startsWith("is"))
+			{
+				continue;
+			}
+			
+			Type[] types = method.getArgumentTypes();
+			Class[] args = new Class[types.length];
+			for (int i = 0; i<types.length; i++)
+			{
+				args[i] = type2Class(types[i]);
+			}
+			
+			try
+			{
+				ret.add(clazz.getDeclaredMethod(method.getName(), args));
+			}
+			catch (SecurityException e)
+			{
+				throw new DynaFormException(e);
+			}
+			catch (NoSuchMethodException e)
+			{
+				throw new DynaFormException(e);
+			}
+		}
+		return ret.toArray(new Method[ret.size()]);
+	}
+
+	protected Class type2Class(Type type)
+	{
+		if (type instanceof BasicType)
+		{
+			BasicType basicType = (BasicType) type;
+			if (basicType.getType() == BasicType.BOOLEAN.getType())
+			{
+				return boolean.class;
+			}
+			else if (basicType.getType() == BasicType.BYTE.getType())
+			{
+				return byte.class;
+			}
+			else if (basicType.getType() == BasicType.CHAR.getType())
+			{
+				return char.class;
+			}
+			else if (basicType.getType() == BasicType.DOUBLE.getType())
+			{
+				return double.class;
+			}
+			else if (basicType.getType() == BasicType.FLOAT.getType())
+			{
+				return float.class;
+			}
+			else if (basicType.getType() == BasicType.INT.getType())
+			{
+				return int.class;
+			}
+			else if (basicType.getType() == BasicType.LONG.getType())
+			{
+				return long.class;
+			}
+			else if (basicType.getType() == BasicType.SHORT.getType())
+			{
+				return short.class;
+			}
+			else if (basicType.getType() == BasicType.STRING.getType())
+			{
+				return String.class;
+			}
+			else if (basicType.getType() == BasicType.VOID.getType())
+			{
+				return void.class;
+			}
+			throw new IllegalArgumentException("dont know how to map " + basicType);
+		}
+		else if (type instanceof ObjectType)
+		{
+			ObjectType objectType = (ObjectType) type;
+			try
+			{
+				return Class.forName(objectType.getClassName());
+			}
+			catch (ClassNotFoundException e)
+			{
+				throw new DynaFormException(e);
+			}
+		}
+		else if (type instanceof ArrayType)
+		{
+			Class elementType = type2Class(((ArrayType) type).getElementType());
+			return Array.newInstance(elementType, 0).getClass();
+		}
+		
+		throw new IllegalArgumentException("unkown type " + type);
+	}
+
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/BcelHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/BcelHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/BcelHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelper.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelper.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelper.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.ejb;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * Interface for helpers to retrieve class meta information 
+ */
+public interface ClassHelper
+{
+	public Field[] getFields(Class clazz);
+	public Method[] getMethods(Class clazz);
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelperFactory.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelperFactory.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelperFactory.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelperFactory.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.ejb;
+
+public class ClassHelperFactory
+{
+	private static ClassHelper classHelper = null;
+	
+	private ClassHelperFactory()
+	{
+	}
+	
+	public static ClassHelper get()
+	{
+		if (classHelper != null)
+		{
+			return classHelper;
+		}
+		
+		classHelper = create();
+		
+		return classHelper;
+	}
+
+	private static ClassHelper create()
+	{
+		try
+		{
+			Class.forName("org.apache.bcel.classfile.JavaClass");
+			return new BcelHelper();
+		}
+		catch (ClassNotFoundException e)
+		{
+            // bcel not there
+        }
+		
+		// last exit
+		return new JavaHelper();
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelperFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelperFactory.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/ClassHelperFactory.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/EjbExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/EjbExtractor.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/EjbExtractor.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/EjbExtractor.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,668 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.ejb;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Set;
+import java.util.Stack;
+import java.util.TreeSet;
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+import javax.persistence.Embedded;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToMany;
+import javax.persistence.ManyToOne;
+import javax.persistence.MappedSuperclass;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Temporal;
+import javax.persistence.Transient;
+import javax.persistence.Version;
+
+import org.apache.myfaces.custom.dynaForm.annot.ui.DisplayOnly;
+import org.apache.myfaces.custom.dynaForm.annot.ui.IgnoreProperty;
+import org.apache.myfaces.custom.dynaForm.annot.ui.ReadOnly;
+import org.apache.myfaces.custom.dynaForm.annot.ui.UIComponent;
+import org.apache.myfaces.custom.dynaForm.annot.ui.Min;
+import org.apache.myfaces.custom.dynaForm.annot.ui.Max;
+import org.apache.myfaces.custom.dynaForm.annot.ui.Range;
+import org.apache.myfaces.custom.dynaForm.annot.ui.NotNull;
+import org.apache.myfaces.custom.dynaForm.annot.ui.Length;
+import org.apache.myfaces.custom.dynaForm.metadata.Extractor;
+import org.apache.myfaces.custom.dynaForm.metadata.MetaData;
+import org.apache.myfaces.custom.dynaForm.metadata.RelationType;
+import org.apache.myfaces.custom.dynaForm.metadata.Selection;
+
+/**
+ * Extract metadata from ejb3 beans
+ */
+public class EjbExtractor implements Extractor
+{
+	private final static Set<String> SYSTEM_METHODS = new TreeSet<String>(
+			Arrays.asList(new String[]
+			{ "hashCode", "getClass", "wait", "equals", "notify", "notifyAll",
+					"toString" }));
+
+	protected static class ContextInfo
+	{
+		private Boolean accessField;
+		private String name;
+		private boolean embedded;
+
+		protected ContextInfo(final String name, final Boolean accessField, final boolean embedded)
+		{
+			super();
+			this.name = name;
+			this.accessField = accessField;
+			this.embedded = embedded;
+		}
+	}
+
+	protected static class Context
+	{
+		private boolean accessField = false;
+		private Stack<ContextInfo> accessFields = new Stack<ContextInfo>();
+		private int embeddLevel = 0;
+
+		public void setAccessField(boolean accessField)
+		{
+			this.accessField = accessField;
+		}
+
+		public Boolean popAccessType()
+		{
+			return accessFields.pop().accessField;
+		}
+
+		public boolean getAccessField()
+		{
+			return accessField;
+		}
+
+		protected void startEmbedded(final String name, final boolean embedded)
+		{
+			embeddLevel++;
+
+			String contextName = name;
+			if (!accessFields.isEmpty())
+			{
+				contextName = accessFields.peek().name + "." + name;
+			}
+
+			accessFields.push(new ContextInfo(contextName, accessField, embedded));
+		}
+
+		protected void endEmbedded()
+		{
+			embeddLevel--;
+			accessField = popAccessType();
+		}
+
+		public String getContextName()
+		{
+			if (accessFields.isEmpty())
+			{
+				return null;
+			}
+
+			return accessFields.peek().name;
+		}
+
+		public boolean isEmbedded()
+		{
+			if (accessFields.isEmpty())
+			{
+				return true;
+			}
+
+			return accessFields.peek().embedded;
+		}
+	}
+
+	public EjbExtractor()
+	{
+	}
+
+	/**
+	 * the entity name as string
+	 */
+	public void getMetaData(MetaData metaData, Object entity)
+	{
+		if (!(entity instanceof String))
+		{
+			throw new IllegalArgumentException("passed entity argument not a string: " + entity);
+		}
+
+		Class entityClass;
+		try
+		{
+			entityClass = Class.forName(entity.toString());
+		}
+		catch (ClassNotFoundException e)
+		{
+			throw new RuntimeException(e);
+		}
+
+		Context context = new Context();
+
+		create(context, metaData, entityClass);
+	}
+
+	/**
+	 * get all super classes needed to be parsed.
+	 */
+	protected void createClassList(List<Class> classes, Class clazz)
+	{
+		Class superClass = clazz.getSuperclass();
+		if (superClass != null && !superClass.equals(Object.class))
+		{
+			createClassList(classes, superClass);
+		}
+
+		classes.add(clazz);
+	}
+
+	/**
+	 * create the metadata for the given class
+	 */
+	@SuppressWarnings("unchecked")
+	protected void create(Context context, MetaData metaData, Class entityClass)
+	{
+		/* do not check if this is really a entity. this allows us to parse any given bean
+		if (!entityClass.isAnnotationPresent(Entity.class))
+		{
+			throw new IllegalArgumentException(entityClass.getName()
+					+ " is not a ejb3 bean");
+		}
+		*/
+
+		List<Class> classes = new ArrayList<Class>(10);
+		createClassList(classes, entityClass);
+
+		for (Class clazz : classes)
+		{
+			boolean accessByField = context.getAccessField();
+
+			Boolean determinedAccessByField = determineAccessByField(entityClass);
+			if (determinedAccessByField != null)
+			{
+				accessByField = determinedAccessByField.booleanValue();
+			}
+
+			if (accessByField)
+			{
+				context.setAccessField(true);
+				initFromFields(context, metaData, getFields(clazz));
+			}
+			else
+			{
+				context.setAccessField(false);
+				initFromMethods(context, metaData, getMethods(clazz));
+			}
+		}
+	}
+
+	protected Boolean determineAccessByField(Class clazz)
+	{
+		Class checkClass = clazz;
+		while (checkClass != null && !checkClass.equals(Object.class))
+		{
+			Method[] methods = checkClass.getDeclaredMethods();
+			for (Method method : methods)
+			{
+				if (method.isSynthetic())
+				{
+					continue;
+				}
+
+				if (method.isAnnotationPresent(Id.class) || method.isAnnotationPresent(EmbeddedId.class))
+				{
+					return Boolean.FALSE;
+				}
+			}
+
+			Field[] fields = checkClass.getDeclaredFields();
+			for (Field field : fields)
+			{
+				if (field.isSynthetic())
+				{
+					continue;
+				}
+
+				if (field.isAnnotationPresent(Id.class) || field.isAnnotationPresent(EmbeddedId.class))
+				{
+					return Boolean.TRUE;
+				}
+			}
+
+			checkClass = checkClass.getSuperclass();
+		}
+
+		return null;
+	}
+
+	protected Method[] getMethods(Class entityClass)
+	{
+		return ClassHelperFactory.get().getMethods(entityClass);
+	}
+
+	protected Field[] getFields(Class entityClass)
+	{
+		return ClassHelperFactory.get().getFields(entityClass);
+	}
+
+	/**
+	 * ejb3 access through fields
+	 */
+	protected void initFromFields(Context context, MetaData metaData, Field[] fields)
+	{
+		for (Field field : fields)
+		{
+			if (!validModifier(field.getModifiers(), false)
+					|| field.isSynthetic()
+					|| hasAnnotationTransient(field))
+			{
+				continue;
+			}
+			String name = field.getName();
+			Class type = field.getType();
+
+			if (metaData.processField(createFullName(context, name)))
+			{
+				processField(context, metaData, field, name, type, true, true);
+			}
+		}
+	}
+
+	/**
+	 * process the given field - or ist superclass if it is embedded
+	 */
+	protected void processField(Context context, MetaData metaData, AccessibleObject accessibleObject, String name, Class<?> type, Boolean canRead, Boolean canWrite)
+	{
+		if (accessibleObject.isAnnotationPresent(IgnoreProperty.class))
+		{
+			// skip this field
+			return;
+		}
+
+		// embeddable if its annotation with @embedded - also check of @id, it might be a composite-key
+		if (processEmbedded(context, metaData, accessibleObject, name, type))
+		{
+			return;
+		}
+
+		if (metaData.processFieldParent(name))
+		{
+			// we processed this field due to the fact that it was the parent of a requestedField
+			embeddEntity(context, metaData, name, type);
+			// now exit
+			return;
+		}
+
+		MetaData.FieldImpl mdField = metaData.getOrCreateField(createFullName(context, name));
+		mdField.setType(type);
+		if (canRead != null && mdField.getCanRead() == null)
+		{
+			mdField.setCanRead(canRead);
+		}
+		if (canWrite != null && mdField.getCanWrite() == null)
+		{
+			mdField.setCanWrite(canWrite);
+		}
+		mdField.setEmbedded(context.isEmbedded());
+		initFromType(context, mdField, type);
+		initFromAnnotations(context, mdField, accessibleObject);
+	}
+
+	protected boolean processEmbedded(Context context, MetaData metaData, AccessibleObject accessibleObject, String name, Class<?> type)
+	{
+		if (accessibleObject.isAnnotationPresent(Embedded.class) || accessibleObject.isAnnotationPresent(Id.class))
+		{
+			if (type.isAnnotationPresent(Embeddable.class) || type.isAnnotationPresent(MappedSuperclass.class))
+			{
+				// process embedded type
+				try
+				{
+					context.startEmbedded(name, true);
+					create(context, metaData, type);
+				}
+				finally
+				{
+					context.endEmbedded();
+				}
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	/**
+	 * check if we should embedd this entity
+	 */
+	protected boolean checkEmbeddEntity(Context context, MetaData metaData, String name)
+	{
+		String checkName = createFullName(context, name) + ".";
+
+		for (String fieldName : metaData.getRequestedFields())
+		{
+			if (fieldName.startsWith(checkName))
+			{
+				return true;
+			}
+		}
+
+		return false;
+	}
+
+	protected String createFullName(Context context, String name)
+	{
+		if (context.getContextName() != null)
+		{
+			return context.getContextName() + "." + name;
+		}
+		else
+		{
+			return name;
+		}
+	}
+
+	/**
+	 * embedd this entity
+	 */
+	protected void embeddEntity(Context context, MetaData metaData, String name, Class entityType)
+	{
+		// process embedded type
+		boolean previousLock = false;
+		try
+		{
+			boolean processAll = metaData.getRequestedFields().contains(createFullName(context, name + ".*"));
+			if (!processAll)
+			{
+				previousLock = metaData.setLockFields(true);
+			}
+			context.startEmbedded(name, false);
+			create(context, metaData, entityType);
+		}
+		finally
+		{
+			context.endEmbedded();
+			metaData.setLockFields(previousLock);
+		}
+	}
+
+	/**
+	 * init metadata from annotations
+	 */
+	protected void initFromAnnotations(Context context, MetaData.FieldImpl mdField, AccessibleObject accessibleObject)
+	{
+		if (accessibleObject.isAnnotationPresent(DisplayOnly.class))
+		{
+			// display only
+			mdField.setDisplayOnly(true);
+		}
+		if (accessibleObject.isAnnotationPresent(ReadOnly.class))
+		{
+			ReadOnly readOnly = accessibleObject.getAnnotation(ReadOnly.class);
+
+			// read-only only
+			mdField.setCanWrite(false);
+			if (readOnly.disabled())
+			{
+				mdField.setDisabled(true);
+			}
+		}
+
+		if (accessibleObject.isAnnotationPresent(UIComponent.class))
+		{
+			UIComponent component = accessibleObject.getAnnotation(UIComponent.class);
+			mdField.setWantedComponentType(component.type());
+		}
+
+		if (accessibleObject.isAnnotationPresent(Column.class))
+		{
+			// is required
+			Column column = accessibleObject.getAnnotation(Column.class);
+			mdField.setRequired(!column.nullable());
+		}
+
+		if (accessibleObject.isAnnotationPresent(Id.class))
+		{
+			// id column cant be written if its a generated value
+			if (accessibleObject.isAnnotationPresent(GeneratedValue.class))
+			{
+				setSpecialFieldDisabled(mdField);
+			}
+		}
+
+		if (accessibleObject.isAnnotationPresent(Version.class))
+		{
+			setSpecialFieldDisabled(mdField);
+		}
+
+		if (accessibleObject.isAnnotationPresent(OneToOne.class))
+		{
+			mdField.setRelationType(RelationType.ONE_TO_ONE);
+		}
+		if (accessibleObject.isAnnotationPresent(OneToMany.class))
+		{
+			mdField.setRelationType(RelationType.ONE_TO_MANY);
+		}
+		if (accessibleObject.isAnnotationPresent(ManyToOne.class))
+		{
+			mdField.setRelationType(RelationType.MANY_TO_ONE);
+		}
+		if (accessibleObject.isAnnotationPresent(ManyToMany.class))
+		{
+			mdField.setRelationType(RelationType.MANY_TO_MANY);
+		}
+
+		// get Temporal from model ...
+		if (accessibleObject.isAnnotationPresent(Temporal.class))
+		{
+			Temporal temporal = accessibleObject.getAnnotation(Temporal.class);
+			mdField.setTemporalType(temporal.value());
+		}
+		// ... but override with our own Temporal if required
+		if (accessibleObject.isAnnotationPresent(org.apache.myfaces.custom.dynaForm.annot.ui.Temporal.class))
+		{
+			org.apache.myfaces.custom.dynaForm.annot.ui.Temporal temporal = accessibleObject.getAnnotation(org.apache.myfaces.custom.dynaForm.annot.ui.Temporal.class);
+			mdField.setTemporalType(temporal.value());
+		}
+
+		Class<?> type = mdField.getType();
+		if (type.isAnnotationPresent(Entity.class))
+		{
+			mdField.setEntityType(true);
+		}
+
+        if (accessibleObject.isAnnotationPresent(Min.class))
+		{
+			Min annot = accessibleObject.getAnnotation(Min.class);
+			mdField.setMinValue((double) annot.value());
+		}
+		if (accessibleObject.isAnnotationPresent(Max.class))
+		{
+			Max annot = accessibleObject.getAnnotation(Max.class);
+			mdField.setMaxValue((double) annot.value());
+		}
+		if (accessibleObject.isAnnotationPresent(Length.class))
+		{
+			Length annot = accessibleObject.getAnnotation(Length.class);
+			mdField.setMinSize(annot.min());
+			mdField.setMaxSize(annot.max());
+		}
+		if (accessibleObject.isAnnotationPresent(NotNull.class))
+		{
+			mdField.setRequired(true);
+		}
+		if (accessibleObject.isAnnotationPresent(Range.class))
+		{
+			Range annot = accessibleObject.getAnnotation(Range.class);
+			mdField.setMinValue((double) annot.min());
+			mdField.setMaxValue((double) annot.max());
+		}
+	}
+
+	/**
+	 * configure a special fields as disabled. e.g. used for Id, Version, ....
+	 */
+	protected void setSpecialFieldDisabled(MetaData.FieldImpl mdField)
+	{
+		mdField.setCanWrite(false);
+		mdField.setDisabled(true);
+	}
+
+	/**
+	 * ejb3 access through methods (properties)
+	 */
+	protected void initFromMethods(Context context, MetaData metaData, Method[] methods)
+	{
+		for (Method method : methods)
+		{
+			if (!validModifier(method.getModifiers(), true)
+					|| method.isSynthetic()
+					|| hasAnnotationTransient(method)
+					|| SYSTEM_METHODS.contains(method.getName()))
+			{
+				continue;
+			}
+			String methodName = method.getName();
+			String propertyName = convertMethodName(methodName);
+
+			if (!metaData.processField(createFullName(context, propertyName)))
+			{
+				continue;
+			}
+
+			if (methodName.startsWith("get") || methodName.startsWith("is"))
+			{
+				Class[] parameters = method.getParameterTypes();
+				if (parameters != null && parameters.length > 0)
+				{
+					// not a bean getter
+					continue;
+				}
+
+				processField(context, metaData, method, propertyName, method.getReturnType(), true, null);
+			}
+			else if (methodName.startsWith("set"))
+			{
+				if (!void.class.equals(method.getReturnType()) && !Void.class.equals(method.getReturnType()))
+				{
+					// not a bean setter
+					continue;
+				}
+
+				Class[] parameters = method.getParameterTypes();
+				if (parameters != null && parameters.length != 1)
+				{
+					// not a bean setter
+					continue;
+				}
+
+				if (metaData.processField(createFullName(context, propertyName)))
+				{
+					processField(context, metaData, method, propertyName, method.getParameterTypes()[0], null, true);
+				}
+			}
+		}
+	}
+
+	@SuppressWarnings("unchecked")
+	protected void initFromType(Context context, org.apache.myfaces.custom.dynaForm.metadata.MetaData.FieldImpl mdField, Class type)
+	{
+		if (type.isEnum())
+		{
+			EnumSet es = EnumSet.allOf(type);
+			Object[] enums = es.toArray(new Object[]{es.size()});
+
+			Selection[] selections = new Selection[enums.length];
+			for (int i = 0; i<enums.length; i++)
+			{
+				Enum e = (Enum) enums[i];
+				selections[i] = new Selection(e.name(), e);
+			}
+
+			mdField.setAllowedSelections(selections);
+		}
+		/*
+		else if (Number.class.isAssignableFrom(type))
+		{
+		}
+		*/
+	}
+
+	/**
+	 * get rid of get/set/is in method names
+	 */
+	protected String convertMethodName(String name)
+	{
+		if (name.startsWith("get"))
+		{
+			name = name.substring("get".length());
+		}
+		else if (name.startsWith("set"))
+		{
+			name = name.substring("set".length());
+		}
+		else if (name.startsWith("is"))
+		{
+			name = name.substring("is".length());
+		}
+		return Character.toLowerCase(name.charAt(0)) + name.substring(1);
+	}
+
+	/**
+	 * skip method/fields annotated with transient
+	 */
+	protected boolean hasAnnotationTransient(AccessibleObject accessibleObject)
+	{
+		return accessibleObject.isAnnotationPresent(Transient.class);
+	}
+
+	/**
+	 * skip method/fields marked as static/transient
+	 */
+	protected boolean validModifier(int modifier, boolean isMethod)
+	{
+		if (isMethod && !Modifier.isPublic(modifier))
+		{
+			return false;
+		}
+		if (Modifier.isStatic(modifier))
+		{
+			return false;
+		}
+		if (Modifier.isTransient(modifier))
+		{
+			return false;
+		}
+
+		return true;
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/EjbExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/EjbExtractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/EjbExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/JavaHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/JavaHelper.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/JavaHelper.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/JavaHelper.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.ejb;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+/**
+ * Extracts fields/methods of the given java class.
+ * 
+ * @see org.apache.myfaces.custom.dynaForm.metadata.impl.ejb.BcelHelper
+ */
+public class JavaHelper implements ClassHelper
+{
+	public Field[] getFields(Class clazz)
+	{
+		return clazz.getDeclaredFields();
+	}
+
+	public Method[] getMethods(Class clazz)
+	{
+		return clazz.getDeclaredMethods();
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/JavaHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/JavaHelper.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/ejb/JavaHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/hibernate/HibernateExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/hibernate/HibernateExtractor.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/hibernate/HibernateExtractor.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/hibernate/HibernateExtractor.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.hibernate;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.myfaces.custom.dynaForm.metadata.MetaData.FieldImpl;
+import org.apache.myfaces.custom.dynaForm.metadata.impl.ejb.EjbExtractor;
+
+/**
+ * Extract hibernate specific data 
+ */
+public class HibernateExtractor extends EjbExtractor
+{
+	@Override
+	protected void initFromAnnotations(Context context, FieldImpl mdField, AccessibleObject accessibleObject)
+	{
+        throw new UnsupportedOperationException();
+
+        /*
+		super.initFromAnnotations(context, mdField, accessibleObject);
+
+        if (accessibleObject.isAnnotationPresent(Min.class))
+		{
+			Min annot = accessibleObject.getAnnotation(Min.class);
+			mdField.setMinValue((double) annot.value());
+		}
+		if (accessibleObject.isAnnotationPresent(Max.class))
+		{
+			Max annot = accessibleObject.getAnnotation(Max.class);
+			mdField.setMaxValue((double) annot.value());
+		}
+		if (accessibleObject.isAnnotationPresent(Length.class))
+		{
+			Length annot = accessibleObject.getAnnotation(Length.class);
+			mdField.setMinSize(annot.min());
+			mdField.setMaxSize(annot.max());
+		}
+		if (accessibleObject.isAnnotationPresent(NotNull.class))
+		{
+			mdField.setRequired(true);
+		}
+		if (accessibleObject.isAnnotationPresent(Range.class))
+		{
+			Range annot = accessibleObject.getAnnotation(Range.class);
+			mdField.setMinValue((double) annot.min());
+			mdField.setMaxValue((double) annot.max());
+		}
+		*/
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/hibernate/HibernateExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/hibernate/HibernateExtractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/hibernate/HibernateExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/AbstractJsfExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/AbstractJsfExtractor.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/AbstractJsfExtractor.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/AbstractJsfExtractor.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.jsf;
+
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfig;
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfigs;
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaForm;
+import org.apache.myfaces.custom.dynaForm.metadata.Extractor;
+import org.apache.myfaces.custom.dynaForm.metadata.MetaData;
+
+import java.util.Iterator;
+
+/**
+ * Extract metadata from jsf form.<br />
+ * This will read all facets with "ff_" name prefix
+ */
+public abstract class AbstractJsfExtractor implements Extractor
+{
+	public AbstractJsfExtractor()
+	{
+	}
+
+	public void getMetaData(MetaData metaData, Object entity)
+	{
+		if (!(entity instanceof DynaForm))
+		{
+			throw new IllegalArgumentException("passed entity argument not a DynaForm: " + entity);
+		}
+		
+		create(metaData, (DynaForm) entity);
+	}
+
+	/**
+	 * create the metadata out of the dynaConfigs for the given component
+	 */
+	@SuppressWarnings("unchecked")
+	protected void create(MetaData metaData, DynaForm dynaForm)
+	{
+		DynaConfigs formConfig = dynaForm.getFormConfigs();
+		if (formConfig == null)
+		{
+			return;
+		}
+		
+		Iterator<DynaConfig> entries = formConfig.iterator();
+		while (entries.hasNext())
+		{
+			DynaConfig dynaConfig = entries.next();
+			String name = dynaConfig.getFor();
+			if (name == null)
+			{
+				throw new IllegalArgumentException("'for' in config tag required");
+			}
+			
+			if (metaData.processField(name))
+			{
+				MetaData.FieldImpl field = metaData.getOrCreateField(name);
+				
+				initFromConfig(field, dynaConfig);
+			}
+		}
+	}
+
+	protected abstract void initFromConfig(MetaData.FieldImpl field, DynaConfig config);
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/AbstractJsfExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/AbstractJsfExtractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/AbstractJsfExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExclusiveExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExclusiveExtractor.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExclusiveExtractor.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExclusiveExtractor.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.jsf;
+
+
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfig;
+import org.apache.myfaces.custom.dynaForm.metadata.MetaData;
+
+/**
+ * Extract metadata from jsf form.<br />
+ * This will read all facets with "ff_" name prefix but nothing will be configured.
+ * Its just there to collect which fields to show if in exclusiveFieldMode
+ */
+public class JsfExclusiveExtractor extends AbstractJsfExtractor
+{
+	public JsfExclusiveExtractor()
+	{
+	}
+
+	protected void initFromConfig(MetaData.FieldImpl field, DynaConfig config)
+	{
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExclusiveExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExclusiveExtractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExclusiveExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExtractor.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExtractor.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExtractor.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.jsf;
+
+
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfig;
+import org.apache.myfaces.custom.dynaForm.metadata.MetaData;
+
+/**
+ * Extract metadata from jsf form.<br />
+ * This will read all facets with "ff_" name prefix
+ */
+public class JsfExtractor extends AbstractJsfExtractor
+{
+	public JsfExtractor()
+	{
+	}
+
+	protected void initFromConfig(MetaData.FieldImpl field, DynaConfig config)
+	{
+		config.configureMetaData(field);
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExtractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfRequestFieldExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfRequestFieldExtractor.java?view=auto&rev=464192
==============================================================================
--- myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfRequestFieldExtractor.java (added)
+++ myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfRequestFieldExtractor.java Sun Oct 15 06:33:49 2006
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.myfaces.custom.dynaForm.metadata.impl.jsf;
+
+
+import java.util.Iterator;
+
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfig;
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaConfigs;
+import org.apache.myfaces.custom.dynaForm.component.dynaForm.DynaForm;
+import org.apache.myfaces.custom.dynaForm.metadata.Extractor;
+import org.apache.myfaces.custom.dynaForm.metadata.MetaData;
+
+/**
+ * Extract metadata from jsf form.<br />
+ * This will read all facets with "ff_" name prefix but nothing will be configured.
+ * Its just there to collect which fields to show if in exclusiveFieldMode
+ */
+public class JsfRequestFieldExtractor implements Extractor
+{
+	public JsfRequestFieldExtractor()
+	{
+	}
+
+	public void getMetaData(MetaData metaData, Object entity)
+	{
+		if (!(entity instanceof DynaForm))
+		{
+			throw new IllegalArgumentException("passed entity argument not a DynaForm: " + entity);
+		}
+		
+		create(metaData, (DynaForm) entity);
+	}
+
+	/**
+	 * create the metadata out of the dynaConfigs for the given component
+	 */
+	@SuppressWarnings("unchecked")
+	protected void create(MetaData metaData, DynaForm dynaForm)
+	{
+		DynaConfigs formConfig = dynaForm.getFormConfigs();
+		if (formConfig == null)
+		{
+			return;
+		}
+		
+		Iterator<DynaConfig> entries = formConfig.iterator();
+		while (entries.hasNext())
+		{
+			DynaConfig dynaConfig = entries.next();
+			String name = dynaConfig.getFor();
+			if (name == null)
+			{
+				throw new IllegalArgumentException("'for' in config tag required");
+			}
+			
+			if (metaData.processField(name))
+			{
+				metaData.requestField(name);
+			}
+		}
+	}
+}

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfRequestFieldExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfRequestFieldExtractor.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: myfaces/tomahawk/trunk/sandbox15/core/src/main/java/org/apache/myfaces/custom/dynaForm/metadata/impl/jsf/JsfRequestFieldExtractor.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain