juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfa...@apache.org
Subject svn commit: r713608 - in /webservices/juddi/branches/v3_trunk/juddi-core/src: main/java/org/apache/juddi/model/ test/java/org/apache/juddi/test/
Date Thu, 13 Nov 2008 01:29:07 GMT
Author: jfaath
Date: Wed Nov 12 17:29:06 2008
New Revision: 713608

URL: http://svn.apache.org/viewvc?rev=713608&view=rev
Log:
Imposed a foreign-key relationship between Businesses and TModels to the owning publisher.


Modified:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingTemplate.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessService.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Tmodel.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/TModelTest.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingTemplate.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingTemplate.java?rev=713608&r1=713607&r2=713608&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingTemplate.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BindingTemplate.java
Wed Nov 12 17:29:06 2008
@@ -139,7 +139,7 @@
 	}
 
 	public String retrievePublisherId() {
-		return this.getBusinessService().getBusinessEntity().getPublisherId();
+		return this.getBusinessService().getBusinessEntity().getPublisher().getPublisherId();
 	}
 	public void assignPublisherId(String id) {
 		// Do nothing, the publisher id is set in the parent.

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java?rev=713608&r1=713607&r2=713608&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessEntity.java
Wed Nov 12 17:29:06 2008
@@ -24,6 +24,8 @@
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
 import javax.persistence.OneToMany;
 import javax.persistence.Table;
 import javax.persistence.OrderBy;
@@ -39,8 +41,8 @@
 	private static final long serialVersionUID = 1L;
 	private String businessKey;
 	private String authorizedName;
-	private String publisherId;
 	private String operator;
+	private UddiEntityPublisher publisher;
 	private Set<Contact> contacts = new HashSet<Contact>(0);
 	private Set<BusinessIdentifier> businessIdentifiers = new HashSet<BusinessIdentifier>(0);
 	private Set<PublisherAssertion> publisherAssertionsForFromKey = new HashSet<PublisherAssertion>(0);
@@ -61,7 +63,7 @@
 		this.lastUpdate = lastUpdate;
 	}
 	public BusinessEntity(String businessKey, String authorizedName, 
-			String publisherId, String operator,
+			UddiEntityPublisher publisher, String operator,
 			Date lastUpdate, Set<Contact> contacts,
 			Set<BusinessIdentifier> businessIdentifiers,
 			Set<PublisherAssertion> publisherAssertionsForFromKey,
@@ -72,7 +74,7 @@
 			Set<BusinessDescr> businessDescrs) {
 		this.businessKey = businessKey;
 		this.authorizedName = authorizedName;
-		this.publisherId = publisherId;
+		this.publisher = publisher;
 		this.operator = operator;
 		this.lastUpdate = lastUpdate;
 		this.contacts = contacts;
@@ -104,12 +106,13 @@
 		this.authorizedName = authorizedName;
 	}
 
-	@Column(name = "publisher_id", length = 20)
-	public String getPublisherId() {
-		return this.publisherId;
+	@ManyToOne(fetch = FetchType.LAZY)
+	@JoinColumn(name = "publisher_id", nullable = false)
+	public UddiEntityPublisher getPublisher() {
+		return this.publisher;
 	}
-	public void setPublisherId(String publisherId) {
-		this.publisherId = publisherId;
+	public void setPublisher(UddiEntityPublisher publisher) {
+		this.publisher = publisher;
 	}
 
 	@Column(name = "operator", nullable = false)
@@ -202,11 +205,14 @@
 	}
 
 	public String retrievePublisherId() {
-		return this.publisherId;
+		return this.publisher.getPublisherId();
 	}
 	public void assignPublisherId(String id) {
-		if (id != null)
-			this.publisherId = id;
+		if (id != null) {
+			Publisher pub = new Publisher();
+			pub.setPublisherId(id);
+			this.setPublisher(pub);
+		}
 	}
 	
 }

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessService.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessService.java?rev=713608&r1=713607&r2=713608&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessService.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/BusinessService.java
Wed Nov 12 17:29:06 2008
@@ -117,7 +117,7 @@
 	}
 
 	public String retrievePublisherId() {
-		return this.getBusinessEntity().getPublisherId();
+		return this.getBusinessEntity().getPublisher().getPublisherId();
 	}
 	public void assignPublisherId(String id) {
 		// Do nothing, the publisher id is set in the parent.

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Tmodel.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Tmodel.java?rev=713608&r1=713607&r2=713608&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Tmodel.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Tmodel.java
Wed Nov 12 17:29:06 2008
@@ -24,6 +24,8 @@
 import javax.persistence.Entity;
 import javax.persistence.FetchType;
 import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
 import javax.persistence.OneToMany;
 import javax.persistence.Table;
 
@@ -38,7 +40,7 @@
 	private static final long serialVersionUID = 1L;
 	private String tmodelKey;
 	private String authorizedName;
-	private String publisherId;
+	private UddiEntityPublisher publisher;
 	private String operator;
 	private String name;
 	private String langCode;
@@ -58,14 +60,14 @@
 		this.name = name;
 		this.lastUpdate = lastUpdate;
 	}
-	public Tmodel(String tmodelKey, String authorizedName, String publisherId, String operator,
+	public Tmodel(String tmodelKey, String authorizedName, UddiEntityPublisher publisher, String
operator,
 			String name, String langCode, boolean deleted, Date lastUpdate,
 			Set<TmodelDescr> tmodelDescrs, Set<TmodelDocDescr> tmodelDocDescrs,
 			Set<TmodelIdentifier> tmodelIdentifiers,
 			Set<TmodelCategory> tmodelCategories) {
 		this.tmodelKey = tmodelKey;
 		this.authorizedName = authorizedName;
-		this.publisherId = publisherId;
+		this.publisher = publisher;
 		this.operator = operator;
 		this.name = name;
 		this.langCode = langCode;
@@ -94,12 +96,13 @@
 		this.authorizedName = authorizedName;
 	}
 
-	@Column(name = "publisher_id", length = 20)
-	public String getPublisherId() {
-		return this.publisherId;
+	@ManyToOne(fetch = FetchType.LAZY)
+	@JoinColumn(name = "publisher_id", nullable = false)
+	public UddiEntityPublisher getPublisher() {
+		return this.publisher;
 	}
-	public void setPublisherId(String publisherId) {
-		this.publisherId = publisherId;
+	public void setPublisher(UddiEntityPublisher publisher) {
+		this.publisher = publisher;
 	}
 
 	@Column(name = "operator", nullable = false)
@@ -167,11 +170,14 @@
 	}
 
 	public String retrievePublisherId() {
-		return this.publisherId;
+		return this.publisher.getPublisherId();
 	}
 	public void assignPublisherId(String id) {
-		if (id != null)
-			this.publisherId = id;
+		if (id != null) {
+			Publisher pub = new Publisher();
+			pub.setPublisherId(id);
+			this.setPublisher(pub);
+		}
 	}
 
 }

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/TModelTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/TModelTest.java?rev=713608&r1=713607&r2=713608&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/TModelTest.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/TModelTest.java
Wed Nov 12 17:29:06 2008
@@ -64,6 +64,9 @@
 			
 			dt.getTModelKey().add(tmodelKey);
 			publish.deleteTModel(dt);
+			
+			// Above call will only do a lazy deletion.  Must remove outside of API to clean database.
+			UDDIApiTestHelper.deleteEntity(org.apache.juddi.model.Tmodel.class, tmodelKey);
 		}
 		catch(DispositionReportFaultMessage dr) {
 			Assert.fail("No exception should be thrown", dr);

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java?rev=713608&r1=713607&r2=713608&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/test/java/org/apache/juddi/test/UDDIApiTestHelper.java
Wed Nov 12 17:29:06 2008
@@ -64,9 +64,11 @@
 		TModel apiTModel = (TModel)buildEntityFromDoc(sourceDir + "root_tModelKeyGen.xml", "org.uddi.api_v3");
 		
 		org.apache.juddi.model.Tmodel modelTModel = new org.apache.juddi.model.Tmodel();
-
+		
 		MappingApiToModel.mapTModel(apiTModel, modelTModel);
 		
+		modelTModel.assignPublisherId(ROOT_PUBLISHER);
+		
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		tx.begin();
@@ -80,33 +82,23 @@
 
 	
 	public static void removeRootPublisher() {
-		
-		EntityManager em = PersistenceManager.getEntityManager();
-		EntityTransaction tx = em.getTransaction();
-		tx.begin();
-
-		Object obj = em.find(org.apache.juddi.model.UddiEntityPublisher.class, ROOT_PUBLISHER);
-		if (obj != null)
-			em.remove(obj);
-		
-		tx.commit();
-		em.close();
-
+		deleteEntity(org.apache.juddi.model.UddiEntityPublisher.class, ROOT_PUBLISHER);
 	}
 
 	public static void removeRootPublisherKeyGen() {
-		
+		deleteEntity(org.apache.juddi.model.Tmodel.class, ROOT_PUBLISHER_KEYGEN);
+	}
+
+	public static void deleteEntity(Class<?> entityClass, Object entityKey) {
 		EntityManager em = PersistenceManager.getEntityManager();
 		EntityTransaction tx = em.getTransaction();
 		tx.begin();
 
-		Object obj = em.find(org.apache.juddi.model.Tmodel.class, ROOT_PUBLISHER_KEYGEN);
-		if (obj != null)
-			em.remove(obj);
+		Object obj = em.find(entityClass, entityKey);
+		em.remove(obj);
 		
 		tx.commit();
 		em.close();
-
 	}
 
 	public static void removeAuthTokens() {



---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org


Mime
View raw message