Permalink
Browse files

Added the getId method used to generate a proxy specific identificati…

…on string to map the current proxy element with the element that will be stored within the persistent layer.
  • Loading branch information...
1 parent 12bfaec commit c733519088825c70b1256fd63ad8d56579b119ff @ccorsi committed Oct 7, 2010
@@ -68,6 +68,17 @@ public void setName(String name) {
}
}
+ /**
+ * @return return the unique object identification for this proxy gender instance
+ */
+ public String getId() {
+ if (gender != null) {
+ return BooksManager.getInstance().getIdentifier(gender);
+ } else {
+ return this.name;
+ }
+ }
+
public String toString() {
return (this.gender != null) ? "[Gender: " + this.gender.getName() + "]" : "[Gender: " + this.name + "]";
}
@@ -149,4 +149,32 @@ public String getFullName() {
return fullname;
}
+ public String getId() {
+ if (person == null) {
+ return generateIdentification();
+ } else {
+ return BooksManager.getInstance().getIdentifier(person);
+ }
+ }
+
+ private String generateIdentification() {
+ StringBuilder name = new StringBuilder();
+ // Add the last name first...
+ if (!this.lastnames.isEmpty()) {
+ for(String lastname : this.lastnames) {
+ name.append(lastname).append(' ');
+ }
+ // Replace trailing space with a comma
+ name.setCharAt(name.length() - 1, ',');
+ }
+ // Add the first name next...
+ name.append(this.firstname);
+ // Add the middle names last...
+ if (!this.middlenames.isEmpty()) {
+ for (String middlename : this.middlenames) {
+ name.append(' ').append(middlename);
+ }
+ }
+ return name.toString();
+ }
}

0 comments on commit c733519

Please sign in to comment.