Skip to content

Commit

Permalink
Merge pull request #20 from LibraryOfCongress/code_cleanup
Browse files Browse the repository at this point in the history
Code cleanup
  • Loading branch information
johnscancella committed Feb 5, 2016
2 parents 2964c14 + fc0701c commit 871f34d
Show file tree
Hide file tree
Showing 72 changed files with 677 additions and 5,258 deletions.
3 changes: 2 additions & 1 deletion bagger-business/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ dependencies {
compile 'org.springframework.boot:spring-boot-starter-logging:1.3.2.RELEASE'
compile 'org.springframework:spring-core:2.5.1',
'org.springframework:spring-beans:2.5.1',
'org.springframework:spring-context:2.5.1'
'org.springframework:spring-context:2.5.1',
'org.json:json:20151123'
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package gov.loc.repository.bagger;

import gov.loc.repository.bagger.json.JSONException;
import gov.loc.repository.bagger.json.JSONObject;
import gov.loc.repository.bagger.json.JSONTokener;
import gov.loc.repository.bagger.json.JSONWriter;

import java.io.Serializable;
import java.io.StringWriter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.json.JSONWriter;

/**
*
| (Contact-Name: Edna Janssen )
Expand All @@ -15,22 +16,24 @@
*
* @author Jon Steinbach
*/
public class Contact {
public class Contact implements Serializable{
private static final long serialVersionUID = 1L;

private ProfileField contactName;
private ProfileField telephone;
private ProfileField email;

public static String FIELD_CONTACT_NAME = "Contact-Name";
public static String FIELD_CONTACT_PHONE = "Contact-Phone";
public static String FIELD_CONTACT_EMAIL = "Contact-Email";
public static final String FIELD_CONTACT_NAME = "Contact-Name";
public static final String FIELD_CONTACT_PHONE = "Contact-Phone";
public static final String FIELD_CONTACT_EMAIL = "Contact-Email";

public static String FIELD_TO_CONTACT_NAME = "To-Contact-Name";
public static String FIELD_TO_CONTACT_PHONE = "To-Contact-Phone";
public static String FIELD_TO_CONTACT_EMAIL = "To-Contact-Email";
public static final String FIELD_TO_CONTACT_NAME = "To-Contact-Name";
public static final String FIELD_TO_CONTACT_PHONE = "To-Contact-Phone";
public static final String FIELD_TO_CONTACT_EMAIL = "To-Contact-Email";

public static String FIELD_JSON_NAME = "name";
public static String FIELD_JSON_PHONE = "phone";
public static String FIELD_JSON_EMAIL = "email";
public static final String FIELD_JSON_NAME = "name";
public static final String FIELD_JSON_PHONE = "phone";
public static final String FIELD_JSON_EMAIL = "email";

public Contact() {
}
Expand Down Expand Up @@ -100,20 +103,23 @@ public static Contact createContact(JSONObject contactSendToJson, boolean sendTo
if (contactSendToJson != null) {
if (contactSendToJson.has(FIELD_JSON_NAME)) {
JSONObject nameJson = (JSONObject) contactSendToJson.get(FIELD_JSON_NAME);
if (nameJson != null)
if (nameJson != null){
namefield = ProfileField.createProfileField(nameJson, name);
}
}

if (contactSendToJson.has(FIELD_JSON_PHONE)) {
JSONObject phoneJson = (JSONObject) contactSendToJson.get(FIELD_JSON_PHONE);
if (phoneJson != null)
if (phoneJson != null){
phonefield = ProfileField.createProfileField(phoneJson, phone);
}
}

if (contactSendToJson.has(FIELD_JSON_EMAIL)) {
JSONObject emailJson = (JSONObject) contactSendToJson.get(FIELD_JSON_EMAIL);
if (emailJson != null)
if (emailJson != null){
emailfield = ProfileField.createProfileField(emailJson, email);
}
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package gov.loc.repository.bagger;

import gov.loc.repository.bagger.json.JSONException;
import gov.loc.repository.bagger.json.JSONObject;
import gov.loc.repository.bagger.json.JSONTokener;
import gov.loc.repository.bagger.json.JSONWriter;

import java.io.StringWriter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.json.JSONWriter;

public class Organization {
private ProfileField name;
private ProfileField address;

public static String FIELD_SOURCE_ORGANIZATION = "Source-Organization";
public static String FIELD_ORGANIZATION_ADDRESS = "Organization-Address";
public static final String FIELD_SOURCE_ORGANIZATION = "Source-Organization";
public static final String FIELD_ORGANIZATION_ADDRESS = "Organization-Address";

public Organization() {
name = new ProfileField();
Expand Down Expand Up @@ -44,10 +44,12 @@ public String toString() {

public String toString(boolean inline) {
String delim;
if (inline)
if (inline){
delim = ", ";
else
}
else{
delim = "\n";
}
StringBuffer sb = new StringBuffer();
sb.append(this.getName());
sb.append(delim);
Expand All @@ -63,14 +65,16 @@ public static Organization createOrganization(JSONObject organizationJson) throw
if (organizationJson != null) {
if (organizationJson.has(FIELD_SOURCE_ORGANIZATION)) {
JSONObject jsonObjectOrgName = (JSONObject) organizationJson.get(FIELD_SOURCE_ORGANIZATION);
if (jsonObjectOrgName != null)
if (jsonObjectOrgName != null){
name = ProfileField.createProfileField(jsonObjectOrgName, FIELD_SOURCE_ORGANIZATION);
}
}

if (organizationJson.has(FIELD_ORGANIZATION_ADDRESS)) {
JSONObject jsonObjectOrgAddr = (JSONObject) organizationJson.get(FIELD_ORGANIZATION_ADDRESS);
if (jsonObjectOrgAddr != null)
if (jsonObjectOrgAddr != null){
address = ProfileField.createProfileField(jsonObjectOrgAddr, FIELD_ORGANIZATION_ADDRESS);
}
}
}

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
package gov.loc.repository.bagger;

import gov.loc.repository.bagger.json.JSONException;
import gov.loc.repository.bagger.json.JSONObject;
import gov.loc.repository.bagger.json.JSONTokener;
import gov.loc.repository.bagger.json.JSONWriter;

import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.json.JSONWriter;

public class Profile {
public static String NO_PROFILE_NAME = "<no profile>";
public static final String NO_PROFILE_NAME = "<no profile>";

public static String FIELD_NAME = "name";
public static String FIELD_ORGANIZATION = "Organization";
public static String FIELD_SENDTO = "Send-To";
public static String FIELD_SENDFROM = "Send-From";
public static String FIELD_CUSTOM_INFO = "Custom-info";
public static String FIELD_STANDARD_INFO = "Standard-info";
public static final String FIELD_NAME = "name";
public static final String FIELD_ORGANIZATION = "Organization";
public static final String FIELD_SENDTO = "Send-To";
public static final String FIELD_SENDFROM = "Send-From";
public static final String FIELD_CUSTOM_INFO = "Custom-info";
public static final String FIELD_STANDARD_INFO = "Standard-info";

private Contact sendToContact = new Contact(true);
private Contact sendFromContact = new Contact(false);
Expand Down Expand Up @@ -81,29 +81,33 @@ public static Profile createProfile(JSONObject profileJson, String profileName)
profile.setName(profileName);

JSONObject organizationJson = null;
if (profileJson.has(Profile.FIELD_ORGANIZATION))
if (profileJson.has(Profile.FIELD_ORGANIZATION)){
organizationJson = (JSONObject) profileJson.get(Profile.FIELD_ORGANIZATION);
}

Organization organization = Organization.createOrganization(organizationJson);
profile.setOrganization(organization);

JSONObject contactSendToJson = null;
if (profileJson.has(Profile.FIELD_SENDTO))
if (profileJson.has(Profile.FIELD_SENDTO)){
contactSendToJson = (JSONObject) profileJson.get(Profile.FIELD_SENDTO);
}

Contact sendToContact = Contact.createContact(contactSendToJson, true);
profile.setSendToContact(sendToContact);

JSONObject contactSendFromJson = null;
if (profileJson.has(Profile.FIELD_SENDFROM))
if (profileJson.has(Profile.FIELD_SENDFROM)){
contactSendFromJson = (JSONObject) profileJson.get(Profile.FIELD_SENDFROM);
}

Contact sendFromContact = Contact.createContact(contactSendFromJson, false);
profile.setSendFromContact(sendFromContact);

JSONObject customInfoJson = null;
if (profileJson.has(Profile.FIELD_CUSTOM_INFO))
if (profileJson.has(Profile.FIELD_CUSTOM_INFO)){
customInfoJson = (JSONObject) profileJson.get(Profile.FIELD_CUSTOM_INFO);
}
HashMap<String, ProfileField> fields = getFields(customInfoJson);
profile.setCustomFields(fields);

Expand All @@ -117,8 +121,9 @@ public static HashMap<String, ProfileField> getFields(JSONObject fieldsJson) thr
HashMap<String, ProfileField> profileFields = new HashMap<String, ProfileField>();
if (fieldsJson != null) {
String[] names = JSONObject.getNames(fieldsJson);
if (names == null)
if (names == null){
return profileFields;
}

for (String name : names) {
JSONObject jsonObject = (JSONObject) fieldsJson.get(name);
Expand Down
Loading

0 comments on commit 871f34d

Please sign in to comment.