use of de.janrufmonitor.framework.IPhonenumber in project janrufmonitor by tbrandt77.
the class ThunderbirdTransformer method buildHomeContact.
private ICaller buildHomeContact(Map m) {
IAttributeMap attributes = PIMRuntime.getInstance().getCallerFactory().createAttributeMap();
if (m.containsKey(FIRSTNAME))
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_FIRSTNAME, removeEscapedChars(((mork.Alias) m.get(FIRSTNAME)).getValue())));
if (m.containsKey(LASTNAME))
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_LASTNAME, removeEscapedChars(((mork.Alias) m.get(LASTNAME)).getValue())));
else
return null;
if (m.containsKey(HOME_STREET))
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, removeEscapedChars(((mork.Alias) m.get(HOME_STREET)).getValue())));
if (m.containsKey(HOME_ZIP))
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, ((mork.Alias) m.get(HOME_ZIP)).getValue()));
if (m.containsKey(HOME_CITY))
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, removeEscapedChars(((mork.Alias) m.get(HOME_CITY)).getValue())));
if (m.containsKey(HOME_COUNTRY))
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, removeEscapedChars(((mork.Alias) m.get(HOME_COUNTRY)).getValue())));
List phones = new ArrayList();
IPhonenumber pn = null;
if (m.containsKey(HOME_PHONE)) {
pn = this.parsePhonenumber(((mork.Alias) m.get(HOME_PHONE)).getValue());
if (pn != null) {
phones.add(pn);
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber(), IJAMConst.ATTRIBUTE_VALUE_LANDLINE_TYPE));
}
}
if (m.containsKey(FAX_PHONE)) {
pn = this.parsePhonenumber(((mork.Alias) m.get(FAX_PHONE)).getValue());
if (pn != null) {
phones.add(pn);
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber(), IJAMConst.ATTRIBUTE_VALUE_FAX_TYPE));
}
}
if (m.containsKey(MOBILE_PHONE)) {
pn = this.parsePhonenumber(((mork.Alias) m.get(MOBILE_PHONE)).getValue());
if (pn != null) {
phones.add(pn);
attributes.add(PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_NUMBER_TYPE + pn.getTelephoneNumber(), IJAMConst.ATTRIBUTE_VALUE_MOBILE_TYPE));
}
}
if (phones.size() == 0)
return null;
ICaller c = PIMRuntime.getInstance().getCallerFactory().createCaller(null, phones, attributes);
c.setUUID(c.getName().getLastname() + "_" + c.getName().getFirstname() + "_" + c.getPhoneNumber().getTelephoneNumber());
IAttribute cm = PIMRuntime.getInstance().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLERMANAGER, ThunderbirdCallerManager.ID);
c.setAttribute(cm);
return c;
}
use of de.janrufmonitor.framework.IPhonenumber in project janrufmonitor by tbrandt77.
the class GeoCoding method createFieldEditors.
protected void createFieldEditors() {
super.createFieldEditors();
// StringFieldEditor sfe = new StringFieldEditor(
// this.getConfigNamespace()+SEPARATOR+"address",
// this.m_i18n.getString(this.getNamespace(), "address", "label", this.m_language),
// 50,
// this.getFieldEditorParent());
// sfe.setEmptyStringAllowed(false);
// addField(sfe);
StringFieldEditor sfe = new StringFieldEditor(this.getConfigNamespace() + SEPARATOR + "local_street", this.m_i18n.getString(this.getNamespace(), "local_street", "label", this.m_language), 25, this.getFieldEditorParent());
sfe.setEmptyStringAllowed(true);
addField(sfe);
sfe = new StringFieldEditor(this.getConfigNamespace() + SEPARATOR + "local_streetno", this.m_i18n.getString(this.getNamespace(), "local_streetno", "label", this.m_language), 4, this.getFieldEditorParent());
sfe.setEmptyStringAllowed(true);
addField(sfe);
sfe = new StringFieldEditor(this.getConfigNamespace() + SEPARATOR + "local_pcode", this.m_i18n.getString(this.getNamespace(), "local_pcode", "label", this.m_language), 5, this.getFieldEditorParent());
sfe.setEmptyStringAllowed(true);
addField(sfe);
sfe = new StringFieldEditor(this.getConfigNamespace() + SEPARATOR + "local_city", this.m_i18n.getString(this.getNamespace(), "local_city", "label", this.m_language), 25, this.getFieldEditorParent());
sfe.setEmptyStringAllowed(true);
addField(sfe);
sfe = new StringFieldEditor(this.getConfigNamespace() + SEPARATOR + "local_country", this.m_i18n.getString(this.getNamespace(), "local_country", "label", this.m_language), 25, this.getFieldEditorParent());
sfe.setEmptyStringAllowed(true);
addField(sfe);
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_city").length() == 0) {
IPhonenumber pn = getRuntime().getCallerFactory().createPhonenumber(getRuntime().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_AREACODE).substring(1) + "123456789");
ICaller c = Identifier.identifyDefault(getRuntime(), pn);
if (c != null && c.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_CITY)) {
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local_city", c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY).getValue());
}
}
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_country").length() == 0) {
IPhonenumber pn = getRuntime().getCallerFactory().createPhonenumber("111111111111111");
ICaller c = Identifier.identifyDefault(getRuntime(), pn);
if (c != null && c.getAttributes().contains(IJAMConst.ATTRIBUTE_NAME_COUNTRY)) {
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local_country", c.getAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY).getValue());
}
}
}
use of de.janrufmonitor.framework.IPhonenumber in project janrufmonitor by tbrandt77.
the class EditorFilterWizard method performFinish.
public boolean performFinish() {
if (this.m_pages[0].isPageComplete()) {
List filterList = new ArrayList();
IPhonenumber phones = ((EditorFilterPhonePage) this.m_pages[0]).getResult();
if (phones != null) {
filterList.add(new PhonenumberFilter(phones));
}
this.m_filters = new IFilter[filterList.size()];
for (int i = 0; i < filterList.size(); i++) {
this.m_filters[i] = (IFilter) filterList.get(i);
}
return true;
}
this.m_filters = null;
return false;
}
use of de.janrufmonitor.framework.IPhonenumber in project janrufmonitor by tbrandt77.
the class GeoDistance method getDistance.
private String getDistance(double lng, double lat) {
// get current location
Point local = GeoCoder.getInstance().getLocalPosition();
if (local == null) {
if (PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty("service.GeoCoding", "local-geo-acc").length() > 0) {
local = new Point(Double.parseDouble(PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty("service.GeoCoding", "local-geo-lng")), Double.parseDouble(PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty("service.GeoCoding", "local-geo-lat")), Integer.parseInt(PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty("service.GeoCoding", "local-geo-acc")));
GeoCoder.getInstance().setLocalPosition(local);
} else {
String areacode = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_AREACODE);
if (areacode != null && areacode.length() > 0) {
IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(areacode + "1234567890");
ICaller caller = Identifier.identifyDefault(PIMRuntime.getInstance(), pn);
if (caller != null) {
local = GeoCoder.getInstance().getCoordinates(caller.getAttributes());
if (local == null)
return "";
GeoCoder.getInstance().setLocalPosition(local);
} else {
return "";
}
} else {
return "";
}
}
}
StringBuffer km = new StringBuffer(10);
DecimalFormat df = new DecimalFormat("0.0");
km.append(df.format(Distance.calculateDistance(new Point(lng, lat), local)));
km.append(" km");
return km.toString();
}
Aggregations