BrightSide Workbench Full Report + Source Code
org.turro.vcard.CSVToRelation Class Reference

Public Member Functions

 CSVToRelation (CSVEntry v)
 
void create ()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 32 of file CSVToRelation.java.

Constructor & Destructor Documentation

◆ CSVToRelation()

org.turro.vcard.CSVToRelation.CSVToRelation ( CSVEntry  v)

Definition at line 36 of file CSVToRelation.java.

36  {
37  entry = v;
38  }

Member Function Documentation

◆ create()

void org.turro.vcard.CSVToRelation.create ( )

Definition at line 40 of file CSVToRelation.java.

40  {
41  Dao dao = new ContactsPU();
42  Contact main = null, related = null;
43  String header = entry.getList().getHeader().getHeader("GID-MAIN");
44  if(header != null) {
45  String value = entry.getField(header);
46  main = contactByGID(dao, value);
47  }
48  if(main == null) {
49  header = entry.getList().getHeader().getPrefixHeader("ID-MAIN");
50  if(header != null) {
51  String prefixValue = null;
52  if(header.length() > "ID-MAIN".length()) {
53  prefixValue = header.substring("ID-MAIN".length() + 1);
54  }
55  String value = prefixValue == null ? entry.getField(header) :
56  entry.getField(header).substring(prefixValue.length());
57  main = contactByConnector(dao, "ID", value);
58  }
59  }
60  header = entry.getList().getHeader().getPrefixHeader("CONNECTOR-REL");
61  if(header != null) {
62  String connector = null;
63  if(header.length() > "CONNECTOR-REL".length()) {
64  connector = header.substring("CONNECTOR-REL".length() + 1);
65  }
66  String value = entry.getField(header);
67  related = contactByConnector(dao, connector, value);
68  }
69  if(main != null && related != null) {
70  header = entry.getList().getHeader().getHeader("RELATION");
71  if(header != null) {
72  String value = entry.getField(header);
73  BusinessRelation relation = new BusinessRelation();
74  relation.setBusiness(main);
75  relation.setContact(related);
76  relation.setDescription(value == null ? "Contacto" : value);
77  dao.saveObject(relation);
78  }
79  }
80  }
Here is the call graph for this function:

The documentation for this class was generated from the following file: