juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ks...@apache.org
Subject svn commit: r725864 - in /webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi: mapping/MappingApiToModel.java mapping/MappingModelToApi.java model/Contact.java model/PersonName.java model/PersonNameId.java
Date Fri, 12 Dec 2008 00:37:57 GMT
Author: kstam
Date: Thu Dec 11 16:37:56 2008
New Revision: 725864

URL: http://svn.apache.org/viewvc?rev=725864&view=rev
Log:
JUDDI-145 Fixing issue 4 as mentioned in the bugreport. Contacts allow a collection of personNames
in v3 as opposed to just the one provided by the model. 

Added:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonName.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonNameId.java
Modified:
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
    webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Contact.java

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java?rev=725864&r1=725863&r2=725864&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingApiToModel.java
Thu Dec 11 16:37:56 2008
@@ -116,16 +116,11 @@
 			List<org.uddi.api_v3.Contact> apiContactList = apiContacts.getContact();
 			int id = 0;
 			for (org.uddi.api_v3.Contact apiContact : apiContactList) {
-				// TODO: The model only supports one personName per contact and it is just a string value
(no language code).
-				List<org.uddi.api_v3.PersonName> apiNameList = apiContact.getPersonName();
-				String personName = null;
-				if (apiNameList != null && apiNameList.size() > 0)
-					personName = ((org.uddi.api_v3.PersonName)apiNameList.get(0)).getValue();
-
 				org.apache.juddi.model.ContactId contactId = new org.apache.juddi.model.ContactId(modelBusinessEntity.getEntityKey(),
id++);
-				org.apache.juddi.model.Contact modelContact = new org.apache.juddi.model.Contact(contactId,
modelBusinessEntity, personName);
+				org.apache.juddi.model.Contact modelContact = new org.apache.juddi.model.Contact(contactId,
modelBusinessEntity);
 				modelContact.setUseType(apiContact.getUseType());
 				
+				mapPersonNames(apiContact.getPersonName(), modelContact.getPersonNames(), modelContact,
modelBusinessEntity.getEntityKey());
 				mapContactDescriptions(apiContact.getDescription(), modelContact.getContactDescrs(),
modelContact, modelBusinessEntity.getEntityKey());
 				mapContactEmails(apiContact.getEmail(), modelContact.getEmails(), modelContact, modelBusinessEntity.getEntityKey());
 				mapContactPhones(apiContact.getPhone(), modelContact.getPhones(), modelContact, modelBusinessEntity.getEntityKey());
@@ -150,6 +145,20 @@
 		}
 	}
 	
+	public static void mapPersonNames(List<org.uddi.api_v3.PersonName> apiPersonNameList,

+			  						  Set<org.apache.juddi.model.PersonName> modelPersonNameList,
+			  						  org.apache.juddi.model.Contact modelContact,
+			  						  String businessKey) 
+				throws DispositionReportFaultMessage {
+		modelPersonNameList.clear();
+		
+		int id = 0;
+		for (org.uddi.api_v3.PersonName apiPersonName : apiPersonNameList) {
+		org.apache.juddi.model.PersonNameId personNameId = new org.apache.juddi.model.PersonNameId(businessKey,
modelContact.getId().getContactId(), id++);
+		modelPersonNameList.add(new org.apache.juddi.model.PersonName(personNameId, modelContact,
apiPersonName.getLang(), apiPersonName.getValue()));
+		}
+	}
+	
 	public static void mapContactEmails(List<org.uddi.api_v3.Email> apiEmailList, 
 										Set<org.apache.juddi.model.Email> modelEmailList,
 										org.apache.juddi.model.Contact modelContact,

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java?rev=725864&r1=725863&r2=725864&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/mapping/MappingModelToApi.java
Thu Dec 11 16:37:56 2008
@@ -124,11 +124,8 @@
 		for (org.apache.juddi.model.Contact modelContact : modelContactList) {
 			org.uddi.api_v3.Contact apiContact = new org.uddi.api_v3.Contact();
 			apiContact.setUseType(modelContact.getUseType());
-			// TODO: The model only supports one person name, needs to support collection.
-			org.uddi.api_v3.PersonName apiPersonName = new org.uddi.api_v3.PersonName();
-			apiPersonName.setValue(modelContact.getPersonName());
-			apiContact.getPersonName().add(apiPersonName);
 			
+			mapPersonNames(modelContact.getPersonNames(), apiContact.getPersonName());
 			mapContactDescriptions(modelContact.getContactDescrs(), apiContact.getDescription());
 			mapContactEmails(modelContact.getEmails(), apiContact.getEmail());
 			mapContactPhones(modelContact.getPhones(), apiContact.getPhone());
@@ -151,6 +148,19 @@
 			apiDescList.add(apiDesc);
 		}
 	}
+	
+	public static void mapPersonNames(Set<org.apache.juddi.model.PersonName> modelPersonNameList,

+			  List<org.uddi.api_v3.PersonName> apiPersonNameList) 
+	throws DispositionReportFaultMessage {
+		apiPersonNameList.clear();
+		
+		for (org.apache.juddi.model.PersonName personName : modelPersonNameList) {
+			org.uddi.api_v3.PersonName apiPersonName = new org.uddi.api_v3.PersonName();
+			apiPersonName.setLang(personName.getLangCode());
+			apiPersonName.setValue(personName.getName());
+			apiPersonNameList.add(apiPersonName);
+		}
+	}
 
 	public static void mapContactEmails(Set<org.apache.juddi.model.Email> modelEmailList,

 										List<org.uddi.api_v3.Email> apiEmailList) 

Modified: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Contact.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Contact.java?rev=725864&r1=725863&r2=725864&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Contact.java
(original)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/Contact.java
Thu Dec 11 16:37:56 2008
@@ -41,7 +41,7 @@
 	private ContactId id;
 	private BusinessEntity businessEntity;
 	private String useType;
-	private String personName;
+	private Set<PersonName> personNames = new HashSet<PersonName>(0);
 	private Set<ContactDescr> contactDescrs = new HashSet<ContactDescr>(0);
 	private Set<Email> emails = new HashSet<Email>(0);
 	private Set<Phone> phones = new HashSet<Phone>(0);
@@ -50,19 +50,17 @@
 	public Contact() {
 	}
 
-	public Contact(ContactId id, BusinessEntity businessEntity,
-			String personName) {
+	public Contact(ContactId id, BusinessEntity businessEntity) {
 		this.id = id;
 		this.businessEntity = businessEntity;
-		this.personName = personName;
 	}
 	public Contact(ContactId id, BusinessEntity businessEntity, String useType,
-			String personName, Set<ContactDescr> contactDescrs,
+			Set<PersonName> personNames, Set<ContactDescr> contactDescrs,
 			Set<Email> emails, Set<Phone> phones, Set<Address> addresses) {
 		this.id = id;
 		this.businessEntity = businessEntity;
 		this.useType = useType;
-		this.personName = personName;
+		this.personNames = personNames;
 		this.contactDescrs = contactDescrs;
 		this.emails = emails;
 		this.phones = phones;
@@ -94,12 +92,13 @@
 		this.useType = useType;
 	}
 
-	@Column(name = "person_name", nullable = false)
-	public String getPersonName() {
-		return this.personName;
+	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "contact")
+	@OrderBy
+	public Set<PersonName> getPersonNames() {
+		return this.personNames;
 	}
-	public void setPersonName(String personName) {
-		this.personName = personName;
+	public void setPersonNames(Set<PersonName> personNames) {
+		this.personNames = personNames;
 	}
 	
 	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "contact")

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonName.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonName.java?rev=725864&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonName.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonName.java
Thu Dec 11 16:37:56 2008
@@ -0,0 +1,91 @@
+package org.apache.juddi.model;
+/*
+ * Copyright 2001-2008 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.
+ */
+
+import javax.persistence.Column;
+import javax.persistence.EmbeddedId;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.JoinColumn;
+import javax.persistence.JoinColumns;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+/**
+ * @author <a href="mailto:kurt@apache.org">Kurt T Stam</a>
+ */
+@Entity
+@Table(name = "person_name")
+public class PersonName implements java.io.Serializable {
+
+	private static final long serialVersionUID = 1L;
+	private PersonNameId id;
+	private Contact contact;
+	private String langCode;
+	private String name;
+
+	public PersonName() {
+	}
+
+	public PersonName(PersonNameId id, Contact contact, String name) {
+		this.id = id;
+		this.contact = contact;
+		this.name = name;
+	}
+	public PersonName(PersonNameId id, Contact contact, String langCode,
+			String name) {
+		this.id = id;
+		this.contact = contact;
+		this.langCode = langCode;
+		this.name = name;
+	}
+
+	@EmbeddedId
+	public PersonNameId getId() {
+		return this.id;
+	}
+	public void setId(PersonNameId id) {
+		this.id = id;
+	}
+
+	@ManyToOne(fetch = FetchType.LAZY)
+	@JoinColumns({
+			@JoinColumn(name = "entity_key", referencedColumnName = "entity_key", nullable = false,
insertable = false, updatable = false),
+			@JoinColumn(name = "contact_id", referencedColumnName = "contact_id", nullable = false,
insertable = false, updatable = false)})
+	public Contact getContact() {
+		return this.contact;
+	}
+	public void setContact(Contact contact) {
+		this.contact = contact;
+	}
+
+	@Column(name = "lang_code", length = 5)
+	public String getLangCode() {
+		return this.langCode;
+	}
+	public void setLangCode(String langCode) {
+		this.langCode = langCode;
+	}
+
+	@Column(name = "name", nullable = false)
+	public String getName() {
+		return this.name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+
+}

Added: webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonNameId.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonNameId.java?rev=725864&view=auto
==============================================================================
--- webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonNameId.java
(added)
+++ webservices/juddi/branches/v3_trunk/juddi-core/src/main/java/org/apache/juddi/model/PersonNameId.java
Thu Dec 11 16:37:56 2008
@@ -0,0 +1,76 @@
+package org.apache.juddi.model;
+/*
+ * Copyright 2001-2008 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.
+ */
+
+import javax.persistence.Column;
+import javax.persistence.Embeddable;
+
+/**
+ * @author <a href="mailto:kurt@apache.org">Kurt T Stam</a>
+ */
+@Embeddable
+public class PersonNameId extends ContactId implements java.io.Serializable {
+
+	private static final long serialVersionUID = 1L;
+	private int personNameId;
+
+	public PersonNameId() {
+	}
+
+	public PersonNameId(String entityKey, int contactId, int personNameId) {
+		this.entityKey = entityKey;
+		this.contactId = contactId;
+		this.personNameId = personNameId;
+	}
+
+	@Column(name = "name_id", nullable = false)
+	public int getPersonNameId() {
+		return this.personNameId;
+	}
+	public void setPersonNameId(int personNameId) {
+		this.personNameId = personNameId;
+	}
+
+	public boolean equals(Object other) {
+		if ((this == other))
+			return true;
+		if ((other == null))
+			return false;
+		if (!(other instanceof PersonNameId))
+			return false;
+		PersonNameId castOther = (PersonNameId) other;
+
+		return ((this.getEntityKey() == castOther.getEntityKey()) || (this
+				.getEntityKey() != null
+				&& castOther.getEntityKey() != null && this.getEntityKey()
+				.equals(castOther.getEntityKey())))
+				&& (this.getContactId() == castOther.getContactId())
+				&& (this.getPersonNameId() == castOther.getPersonNameId());
+	}
+
+	public int hashCode() {
+		int result = 17;
+
+		result = 37
+				* result
+				+ (getEntityKey() == null ? 0 : this.getEntityKey()
+						.hashCode());
+		result = 37 * result + this.getContactId();
+		result = 37 * result + this.getPersonNameId();
+		return result;
+	}
+
+}



---------------------------------------------------------------------
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