use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class XMLCallHandler method startElement.
public void startElement(String uri, String name, String qname, Attributes attributes) throws SAXException {
if (this.m_multi && qname.equalsIgnoreCase(TAG_CALLLIST)) {
this.m_calllist = this.getRuntime().getCallFactory().createCallList();
}
if (qname.equalsIgnoreCase(TAG_CALL)) {
this.m_call = this.getRuntime().getCallFactory().createCall(null, this.getRuntime().getCallFactory().createMsn("", ""), this.getRuntime().getCallFactory().createCip("", ""));
}
if (qname.equalsIgnoreCase(TAG_CALLER)) {
this.m_iscaller = true;
}
if (this.m_iscaller) {
super.startElement(uri, name, qname, attributes);
return;
}
if (qname.equalsIgnoreCase(TAG_UUID)) {
this.m_call.setUUID(attributes.getValue(ATTRIBUTE_VALUE));
}
if (qname.equalsIgnoreCase(TAG_DATE)) {
this.m_call.setDate(new Date(Long.parseLong(attributes.getValue(ATTRIBUTE_VALUE))));
}
if (qname.equalsIgnoreCase(TAG_CIP)) {
ICip cip = this.m_call.getCIP();
cip.setCIP(attributes.getValue(ATTRIBUTE_VALUE));
cip.setAdditional(this.getRuntime().getCipManager().getCipLabel(cip, this.getLanguage()));
this.m_call.setCIP(cip);
}
if (qname.equalsIgnoreCase(TAG_MSN)) {
IMsn msn = this.m_call.getMSN();
msn.setMSN(attributes.getValue(ATTRIBUTE_VALUE));
msn.setAdditional(decode(attributes.getValue(ATTRIBUTE_ADDITIONAL)));
this.m_call.setMSN(msn);
}
if (qname.equalsIgnoreCase(TAG_ATTRIBUTE)) {
IAttribute att = this.getRuntime().getCallerFactory().createAttribute(attributes.getValue(ATTRIBUTE_NAME), decode(attributes.getValue(ATTRIBUTE_VALUE)));
this.m_call.setAttribute(att);
}
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookTransformer method createBusinessCallerList.
private ICallerList createBusinessCallerList(Dispatch contact) throws ComFailException {
ICallerList callerList = getRuntime().getCallerFactory().createCallerList();
IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
IAttribute attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, Dispatch.get(contact, "Firstname").toString().trim());
if (attribute != null)
m.add(attribute);
attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, Dispatch.get(contact, "Lastname").toString().trim());
if (attribute != null)
m.add(attribute);
if (m.size() == 0) {
attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, Dispatch.get(contact, "CompanyName").toString().trim());
if (attribute != null)
m.add(attribute);
} else {
attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_ADDITIONAL, Dispatch.get(contact, "CompanyName").toString().trim());
if (attribute != null)
m.add(attribute);
}
// check if business caller exists
if (m.size() > 0) {
m.addAll(createBusinessAddressAttributes(contact));
List phones = new ArrayList(businessPhones.length);
IPhonenumber phone = getRuntime().getCallerFactory().createPhonenumber(false);
String number = null;
for (int i = 0; i < businessPhones.length; i++) {
number = Dispatch.get(contact, businessPhones[i]).toString().trim();
if (number != null && number.length() > 0) {
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("OutlookTransformer raw number: " + number);
}
phone = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(number);
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("OutlookTransformer identified number: " + phone);
}
if (phone != null) {
if (phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
m.add(getNumberTypeAttribute(businessPhones[i], phone.getTelephoneNumber()));
phones.add(phone);
}
}
}
}
if (phones.size() > 0) {
ICaller outlookCaller = getRuntime().getCallerFactory().createCaller(null, phones, m);
// outlookCaller.setAttributes(m);
outlookCaller.setUUID(outlookCaller.getName().getLastname() + "_" + outlookCaller.getName().getFirstname() + "_" + outlookCaller.getPhoneNumber().getTelephoneNumber());
this.setPictureAttribute(outlookCaller, contact);
IAttribute cm = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, ID);
outlookCaller.setAttribute(cm);
this.m_logger.fine("Created Outlook contact: " + outlookCaller.toString());
callerList.add(outlookCaller);
}
}
return callerList;
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookTransformer method createPrivateAddressAttributes.
private IAttributeMap createPrivateAddressAttributes(Dispatch contact) throws ComFailException {
IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
IAttribute attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, Dispatch.get(contact, "HomeAddressCity").toString().trim());
if (attribute != null)
m.add(attribute);
attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, Dispatch.get(contact, "HomeAddressPostalCode").toString().trim());
if (attribute != null)
m.add(attribute);
attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, Dispatch.get(contact, "HomeAddressStreet").toString().trim());
if (attribute != null)
m.add(attribute);
attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, Dispatch.get(contact, "HomeAddressCountry").toString().trim());
if (attribute != null)
m.add(attribute);
return m;
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookTransformer method createPrivateCallerList.
private ICallerList createPrivateCallerList(Dispatch contact) throws ComFailException {
ICallerList callerList = getRuntime().getCallerFactory().createCallerList();
IAttributeMap m = getRuntime().getCallerFactory().createAttributeMap();
IAttribute attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, Dispatch.get(contact, "Firstname").toString().trim());
if (attribute != null)
m.add(attribute);
attribute = createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, Dispatch.get(contact, "Lastname").toString().trim());
if (attribute != null)
m.add(attribute);
// check if private caller exists
if (m.size() > 0) {
m.addAll(createPrivateAddressAttributes(contact));
List phones = new ArrayList(businessPhones.length);
IPhonenumber phone = getRuntime().getCallerFactory().createPhonenumber(false);
String number = null;
for (int i = 0; i < privatePhones.length; i++) {
number = Dispatch.get(contact, privatePhones[i]).toString().trim();
if (number != null && number.length() > 0) {
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("OutlookTransformer raw number: " + number);
}
phone = PhonenumberAnalyzer.getInstance(getRuntime()).toIdentifiedPhonenumber(number);
if (this.m_logger.isLoggable(Level.INFO)) {
this.m_logger.info("OutlookTransformer identified number: " + phone);
}
if (phone != null) {
if (phone.getTelephoneNumber().trim().length() > 0 && !phone.isClired()) {
m.add(getNumberTypeAttribute(privatePhones[i], phone.getTelephoneNumber()));
phones.add(phone);
}
}
}
}
if (phones.size() > 0) {
ICaller outlookCaller = getRuntime().getCallerFactory().createCaller(null, phones, m);
outlookCaller.setUUID(outlookCaller.getName().getLastname() + "_" + outlookCaller.getName().getFirstname() + "_" + outlookCaller.getPhoneNumber().getTelephoneNumber());
this.setPictureAttribute(outlookCaller, contact);
IAttribute cm = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, ID);
outlookCaller.setAttribute(cm);
this.m_logger.fine("Created Outlook contact: " + outlookCaller.toString());
callerList.add(outlookCaller);
}
}
return callerList;
}
use of de.janrufmonitor.framework.IAttribute in project janrufmonitor by tbrandt77.
the class OutlookTransformer method setPictureAttribute.
private void setPictureAttribute(ICaller outlookCaller, Dispatch contact) {
try {
if (Dispatch.get(contact, "HasPicture").getBoolean()) {
String imagepath = MSO_IMAGE_CACHE_PATH + outlookCaller.getUUID() + ".jpg";
if (!new File(imagepath).exists()) {
Dispatch items = Dispatch.get(contact, "Attachments").toDispatch();
int count = Integer.valueOf(Dispatch.get(items, "Count").toString()).intValue();
if (count > 1)
this.m_logger.info("Found " + count + " attachments for outlook contact " + outlookCaller.toString());
for (int i = 1; i <= count; i++) {
Dispatch item = Dispatch.call(items, "Item", new Integer(i)).toDispatch();
int type = Integer.valueOf(Dispatch.get(item, "Type").toString()).intValue();
// type 1 olAttachmentType = olByValue
if (type == 1) {
try {
String outlookFilename = Dispatch.get(item, "FileName").toString();
if (outlookFilename != null && (outlookFilename.startsWith("ContactPicture") || outlookFilename.startsWith("ContactPhoto"))) {
// imagepath = imagepath.substring(0, imagepath.length()-4) + (i>1? Integer.toString(i) : "") + ".jpg";
Dispatch.call(item, "SaveAsFile", new String(imagepath));
}
} catch (ComFailException ex) {
this.m_logger.warning("Could not get FileName attribute: " + ex.getMessage() + ", " + ex.getSource());
}
}
}
}
IAttribute img = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_IMAGEPATH, PathResolver.getInstance().encode(imagepath));
outlookCaller.setAttribute(img);
}
} catch (ComFailException ex) {
this.m_logger.warning(ex.getMessage() + ", " + ex.getSource());
}
}
Aggregations