// if(o!=null){
// if(o instanceof Human)kind="human";
// else
// kind=o.getClass().getName();
// }
GoogleCsvRow e=d.createRow();
d.appendRow(e);
if(o instanceof Human){
Human h = (Human) o;
GoogleCsvRow he=e;
copyAttr(h,he,"Notes");
//Given Name
//Additional Name
//Family Name
String lastn=h.getLastNameNative();
String firstn=h.getFirstNameNative();
String midn=h.getMiddleNameNative();
if(StringUtil.isEmptyTrimmed(lastn))lastn=h.getLastNameAscii();
if(StringUtil.isEmptyTrimmed(firstn))firstn=h.getFirstNameAscii();
if(StringUtil.isEmptyTrimmed(midn))midn=h.getMiddleNameAscii();
String GivenName=firstn;
String AdditionalName=midn;
String FamilyName=lastn;
he.setColumn("Given Name", GivenName);
he.setColumn("Additional Name", AdditionalName);
he.setColumn("Family Name", FamilyName);
he.setColumn("Nickname", h.getNicks());
List<String> nickList=StringUtil.split(StringUtil.makeEmpty(h.getNicks()),",;");
String firstNick=nickList.isEmpty()?"":nickList.get(0);
firstNick=firstNick.trim();
firstNick=StringUtil.makeNull(firstNick);
String passportName=GivenName+" "+(AdditionalName==null?"":AdditionalName+" ")+FamilyName;
passportName=passportName.trim();
passportName=StringUtil.makeNull(passportName);
String name=passportName==null?firstNick:passportName+(firstNick==null?"":" ("+firstNick+")");
name=name.trim();
he.setColumn("Name", name);
//Organization 1 - Title
String CompaniesAndTitles=h.getCompaniesAndTitles();
List<String> CompaniesAndTitlesList=StringUtil.split(CompaniesAndTitles, "\r\n");
int i=1;
for(String c_and_t:CompaniesAndTitlesList){
String googleColumnName="Organization "+i+" - Title";
he.setColumn(googleColumnName, c_and_t);
i++;
}
//E-mail 1 - Type
//* Home
//E-mail 1 - Value
String Emails=h.getEmails();
List<String> EmailsList=StringUtil.split(Emails, "\r\n");
i=1;
boolean first=true;
for(String eml:EmailsList){
String googleColumnNameType="E-mail "+i+" - Type";
String googleColumnNameValue="E-mail "+i+" - Value";
String googleTypeColumnValue=(first?"* ":"")+"Home";
he.setColumn(googleColumnNameType, googleTypeColumnValue);
he.setColumn(googleColumnNameValue, eml);
i++;
first=false;
}
//Website 1 - Type
//Home
//Website 1 - Value
{
String WebUrls=h.getWebUrls();
List<String> WebUrlsList=StringUtil.split(WebUrls, "\r\n");
i=1;
first=true;
for(String w:WebUrlsList){
String googleColumnNameType="Website "+i+" - Type";
String googleColumnNameValue="Website "+i+" - Value";
String googleTypeColumnValue=(first?"":"")+"Home";
he.setColumn(googleColumnNameType, googleTypeColumnValue);
he.setColumn(googleColumnNameValue, w);
i++;
first=false;
}
}
//Website 2 - Type
//Blog
//Website 2 - Value
{
String WebUrls=h.getBlogs();
List<String> WebUrlsList=StringUtil.split(WebUrls, "\r\n");
//i=1;//continue numbering
//first=true;//continue numbering
for(String w:WebUrlsList){
String googleColumnNameType="Website "+i+" - Type";
String googleColumnNameValue="Website "+i+" - Value";
String googleTypeColumnValue=(first?"":"")+"Blog";
he.setColumn(googleColumnNameType, googleTypeColumnValue);
he.setColumn(googleColumnNameValue, w);
i++;
first=false;
}
}
//Address 1 - Type
//Home
//Address 1 - Formatted
he.setColumn("Address 1 - Type", "Home");
he.setColumn("Address 1 - Formatted", h.getStreetAddress());
//Custom Field 1 - Type
//Date Updated
//Custom Field 1 - Value
//anything
SimpleDateFormat df=new SimpleDateFormat("MMM/dd/yyyy");
he.setColumn("Custom Field 1 - Type", "Date Updated");
he.setColumn("Custom Field 1 - Value",df.format(h.getLastUpdated()));
//Phone 1 - Type
//Home
//Phone 1 - Value
{
String WebUrls=h.getHomePhones();
List<String> WebUrlsList=StringUtil.split(WebUrls, ",;");
i=1;
first=true;
for(String w:WebUrlsList){
String googleColumnNameType="Phone "+i+" - Type";
String googleColumnNameValue="Phone "+i+" - Value";
String googleTypeColumnValue=(first?"":"")+"Home";
he.setColumn(googleColumnNameType, googleTypeColumnValue);
he.setColumn(googleColumnNameValue, w);
i++;
first=false;
}
}
//Phone 2 - Type
//Mobile
//Phone 2 - Value
{
String WebUrls=h.getCellPhones();
List<String> WebUrlsList=StringUtil.split(WebUrls, ",;");
//i=1;//continue numbering
//first=true;//continue numbering
for(String w:WebUrlsList){
String googleColumnNameType="Phone "+i+" - Type";
String googleColumnNameValue="Phone "+i+" - Value";
String googleTypeColumnValue=(first?"":"")+"Mobile";
he.setColumn(googleColumnNameType, googleTypeColumnValue);
he.setColumn(googleColumnNameValue, w);
i++;
first=false;
}
}
//Phone 3 - Type
//Work
//Phone 3 - Value
{
String WebUrls=h.getOfficePhones();
List<String> WebUrlsList=StringUtil.split(WebUrls, ",;");
//i=1;//continue numbering
//first=true;//continue numbering
for(String w:WebUrlsList){
String googleColumnNameType="Phone "+i+" - Type";
String googleColumnNameValue="Phone "+i+" - Value";
String googleTypeColumnValue=(first?"":"")+"Work";
he.setColumn(googleColumnNameType, googleTypeColumnValue);
he.setColumn(googleColumnNameValue, w);
i++;
first=false;
}
}
//IM 1 - Type
//Other
//IM 1 - Service
//Skype ::: ICQ ::: Jabber ::: MSN
//IM 1 - Value
//im-sk ::: im-icq ::: im-jab ::: im-msn
he.setColumn("IM 1 - Type", "Other");
StringBuilder service=new StringBuilder();
StringBuilder value=new StringBuilder();
{
String serviceName="ICQ";
String WebUrls=h.getIcqNumbers();
List<String> WebUrlsList=StringUtil.split(WebUrls, ",;");
first=true;
for(String w:WebUrlsList){
if(service.length()>0)service.append(" ::: ");
service.append(serviceName);
if(value.length()>0)value.append(" ::: ");
value.append(w);
first=false;
}
}
{
String serviceName="Jabber";
String WebUrls=h.getJabberIds();
List<String> WebUrlsList=StringUtil.split(WebUrls, ",;");
//first=true;//not first
for(String w:WebUrlsList){
if(service.length()>0)service.append(" ::: ");
service.append(serviceName);
if(value.length()>0)value.append(" ::: ");
value.append(w);
first=false;
}
}
{
//Skype ::: ICQ ::: Jabber ::: MSN
String serviceName="Skype";
String WebUrls=h.getSkypeLogins();
List<String> WebUrlsList=StringUtil.split(WebUrls, ",;");
//first=true;//not first
for(String w:WebUrlsList){
if(service.length()>0)service.append(" ::: ");
service.append(serviceName);
if(value.length()>0)value.append(" ::: ");
value.append(w);
first=false;
}
}
{
//Skype ::: ICQ ::: Jabber ::: MSN
String serviceName="MSN";
String WebUrls=h.getMsnLogins();
List<String> WebUrlsList=StringUtil.split(WebUrls, ",;");
//first=true;//not first
for(String w:WebUrlsList){
if(service.length()>0)service.append(" ::: ");
service.append(serviceName);
if(value.length()>0)value.append(" ::: ");
value.append(w);
first=false;
}
}
//IM 1 - Service
//Skype ::: ICQ ::: Jabber ::: MSN
//IM 1 - Value
//im-sk ::: im-icq ::: im-jab ::: im-msn
he.setColumn("IM 1 - Service", service.toString());
he.setColumn("IM 1 - Value", value.toString());
}
}
return d.exportAsString();
}