You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2007/03/29 17:50:08 UTC

svn commit: r523753 - in /incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa: XmlDataDAOImpl.java XmlDataProperty.java

Author: mriou
Date: Thu Mar 29 08:50:07 2007
New Revision: 523753

URL: http://svn.apache.org/viewvc?view=rev&rev=523753
Log:
Replacing Properties by a standard persistent object.

Added:
    incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java
Modified:
    incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java

Modified: incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java?view=diff&rev=523753&r1=523752&r2=523753
==============================================================================
--- incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java (original)
+++ incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataDAOImpl.java Thu Mar 29 08:50:07 2007
@@ -37,10 +37,15 @@
 import javax.persistence.Id;
 import javax.persistence.Lob;
 import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
 import javax.persistence.Table;
 import javax.persistence.Transient;
-import java.util.Properties;
+import java.util.ArrayList;
+import java.util.Collection;
 
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
 @Entity
 @Table(name="ODE_XML_DATA")
 public class XmlDataDAOImpl implements XmlDataDAO {
@@ -56,8 +61,9 @@
     private boolean _isSimpleType;
 	@Basic @Column(name="NAME")
     private String _name;
-	@Basic @Column(name="PROPERTIES")
-    private Properties _props = new Properties();
+
+    @OneToMany(targetEntity=XmlDataProperty.class,mappedBy="_xmlData",fetch=FetchType.EAGER,cascade={CascadeType.ALL})
+    private Collection<XmlDataProperty> _props = new ArrayList<XmlDataProperty>();
 
 	@ManyToOne(fetch=FetchType.LAZY,cascade={CascadeType.PERSIST}) @Column(name="SCOPE_ID")
 	private ScopeDAOImpl _scope;
@@ -97,7 +103,10 @@
 	}
 
 	public String getProperty(String propertyName) {
-		return _props.getProperty(propertyName);
+        for (XmlDataProperty prop : _props) {
+            if (prop.getPropertyKey().equals(propertyName)) return prop.getPropertyValue();
+        }
+        return null;
 	}
 
 	public ScopeDAO getScopeDAO() {
@@ -124,7 +133,7 @@
 	}
 
 	public void setProperty(String pname, String pvalue) {
-		_props.setProperty(pname, pvalue);
+        _props.add(new XmlDataProperty(pname, pvalue, this));
 	}
 
 }

Added: incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java?view=auto&rev=523753
==============================================================================
--- incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java (added)
+++ incubator/ode/trunk/dao-jpa/src/main/java/org/apache/ode/dao/jpa/XmlDataProperty.java Thu Mar 29 08:50:07 2007
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.ode.dao.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author Matthieu Riou <mriou at apache dot org>
+ */
+@Entity
+@Table(name="ODE_XML_DATA")
+public class XmlDataProperty {
+
+    @Id @Column(name="ID")
+    @GeneratedValue(strategy= GenerationType.AUTO)
+    private Long _id;
+    @Basic @Column(name="PROP_KEY")
+    private String propertyKey;
+    @Basic @Column(name="PROP_VALUE")
+    private String propertyValue;
+    @ManyToOne(fetch= FetchType.LAZY,cascade={CascadeType.PERSIST})
+    @Column(name="XML_DATA_ID")
+    private XmlDataDAOImpl _xmlData;
+
+    public XmlDataProperty() {
+    }
+    public XmlDataProperty(String propertyKey, String propertyValue, XmlDataDAOImpl xmlData) {
+        this.propertyKey = propertyKey;
+        this.propertyValue = propertyValue;
+        this._xmlData = xmlData;
+    }
+
+    public String getPropertyKey() {
+        return propertyKey;
+    }
+
+    public void setPropertyKey(String propertyKey) {
+        this.propertyKey = propertyKey;
+    }
+
+    public String getPropertyValue() {
+        return propertyValue;
+    }
+
+    public void setPropertyValue(String propertyValue) {
+        this.propertyValue = propertyValue;
+    }
+
+}