use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class BussinessOutlookMapping method getSpecialAttributes.
public IAttributeMap getSpecialAttributes() {
IAttributeMap m = PIMRuntime.getInstance().getCallerFactory().createAttributeMap();
m.add(PIMRuntime.getInstance().getCallerFactory().createAttribute("outlook.business", "true"));
return m;
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class OutlookImportAction method run.
public void run() {
String filter = this.m_app.getApplication().getConfiguration().getProperty("filter", "");
EditorFilterManager efm = new EditorFilterManager();
final IAttribute category = getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CATEGORY, "");
if (filter.length() > 0) {
String cat = null;
IFilter[] filters = efm.getFiltersFromString(filter);
for (int z = 0; z < filters.length; z++) {
if (filters[z].getType().equals(FilterType.ATTRIBUTE)) {
AttributeFilter cf = ((AttributeFilter) filters[z]);
IAttributeMap m = cf.getAttributeMap();
if (m != null && m.size() > 0) {
Iterator it = m.iterator();
IAttribute a = null;
while (it.hasNext()) {
a = (IAttribute) it.next();
if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
cat = a.getValue();
}
}
}
}
}
if (cat != null) {
int style = SWT.APPLICATION_MODAL | SWT.YES | SWT.NO;
MessageBox messageBox = new MessageBox(new Shell(DisplayManager.getDefaultDisplay()), style);
String text = this.getI18nManager().getString("ui.jface.application.editor.action.ImportAction", "assigncategoryconfirm", "label", this.getLanguage());
text = StringUtils.replaceString(text, "{%1}", cat);
messageBox.setMessage(text);
if (messageBox.open() == SWT.YES) {
category.setValue(cat);
}
}
}
// determine subfolders
OutlookTransformer ot = new OutlookTransformer();
List folders = ot.getAllContactFolders();
if (folders.size() > 0) {
int itemCount = 0;
String folder = null;
for (int i = 0, j = folders.size(); i < j; i++) {
folder = (String) folders.get(i);
itemCount = ot.getContactCount(folder);
if (itemCount > 0) {
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(OutlookContactManager.NAMESPACE, "subfolder_" + folder, "true");
}
}
getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
}
ProgressMonitorDialog pmd = new ProgressMonitorDialog(DisplayManager.getDefaultDisplay().getActiveShell());
try {
IRunnableWithProgress r = new IRunnableWithProgress() {
public void run(IProgressMonitor progressMonitor) {
progressMonitor.beginTask(getI18nManager().getString(getNamespace(), "importprogress", "label", getLanguage()), IProgressMonitor.UNKNOWN);
progressMonitor.worked(1);
OutlookTransformer otf = new OutlookTransformer();
ICallerList callers = otf.getCallerListFromAllContacts();
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "reduce", "label", getLanguage()));
otf.removeCallerManagerID(callers);
// determine duplicates
String currentCallerManagerID = m_app.getApplication().getConfiguration().getProperty(CFG_REPOSITORY);
if (currentCallerManagerID != null && currentCallerManagerID.trim().length() > 0) {
ICallerManager currentCallerManager = getRuntime().getCallerManagerFactory().getCallerManager(currentCallerManagerID);
if (currentCallerManager != null && currentCallerManager.isSupported(IWriteCallerRepository.class) && currentCallerManager.isSupported(IIdentifyCallerRepository.class)) {
ICallerList addCallers = getRuntime().getCallerFactory().createCallerList();
// ICallerList removeCallers = getRuntime().getCallerFactory().createCallerList();
ICaller currentCaller = null;
String text = null;
for (int i = 0, j = callers.size(); i < j; i++) {
// ICaller testCaller = null;
currentCaller = callers.get(i);
text = getI18nManager().getString(getNamespace(), "check", "label", getLanguage());
text = StringUtils.replaceString(text, "{%1}", Formatter.getInstance(getRuntime()).parse("%a:ln%, %a:fn%", currentCaller));
progressMonitor.setTaskName(text);
try {
Thread.sleep(100);
} catch (InterruptedException e1) {
}
try {
// testCaller = ((IIdentifyCallerRepository)currentCallerManager).getCaller(currentCaller.getPhoneNumber());
((IIdentifyCallerRepository) currentCallerManager).getCaller(currentCaller.getPhoneNumber());
} catch (CallerNotFoundException e) {
if (category != null && category.getValue().length() > 0)
currentCaller.setAttribute(category);
addCallers.add(currentCaller);
}
// if (testCaller!=null) {
// removeCallers.add(testCaller);
// }
}
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "add", "label", getLanguage()));
try {
Thread.sleep(1250);
} catch (InterruptedException e1) {
}
// if (removeCallers.size()>0)
// m_app.getController().deleteElements(removeCallers);
m_app.getController().addElements(addCallers);
}
} else {
progressMonitor.setTaskName(getI18nManager().getString(getNamespace(), "add", "label", getLanguage()));
m_app.getController().addElements(callers);
}
progressMonitor.done();
}
};
pmd.setBlockOnOpen(false);
pmd.run(true, false, r);
// ModalContext.run(r, true, pmd.getProgressMonitor(), DisplayManager.getDefaultDisplay());
} catch (InterruptedException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
} catch (InvocationTargetException e) {
m_logger.log(Level.SEVERE, e.getMessage(), e);
}
m_app.updateViews(true);
return;
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class GeoCoding method performOk.
public boolean performOk() {
boolean ok = super.performOk();
IAttributeMap address = getRuntime().getCallerFactory().createAttributeMap();
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_street").trim().length() > 0) {
address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_street").trim()));
}
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_streetno").trim().length() > 0) {
address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_STREET_NO, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_streetno").trim()));
}
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_pcode").trim().length() > 0) {
address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_POSTAL_CODE, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_pcode").trim()));
}
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_city").trim().length() > 0) {
address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CITY, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_city").trim()));
}
if (getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_country").trim().length() > 0) {
address.add(getRuntime().getCallerFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_COUNTRY, getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "local_country").trim()));
}
// String address = getRuntime().getConfigManagerFactory().getConfigManager().getProperty(CONFIG_NAMESPACE, "address");
if (address != null && address.size() > 0) {
Point loc = GeoCoder.getInstance().getCoordinates(address);
if (loc != null) {
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local-geo-lng", Double.toString(loc.getLongitude()));
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local-geo-lat", Double.toString(loc.getLatitude()));
getRuntime().getConfigManagerFactory().getConfigManager().setProperty(CONFIG_NAMESPACE, "local-geo-acc", Integer.toString(loc.getAccurance()));
}
GeoCoder.invalidate();
}
return ok;
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class FilterWizard method performFinish.
public boolean performFinish() {
if (this.m_pages[0].isPageComplete() && this.m_pages[1].isPageComplete() && this.m_pages[2].isPageComplete() && this.m_pages[3].isPageComplete() && this.m_pages[4].isPageComplete() && this.m_pages[5].isPageComplete() && this.m_pages[6].isPageComplete()) {
List filterList = new ArrayList();
IPhonenumber[] phones = ((FilterPhonesPage) this.m_pages[3]).getResult();
if (phones != null) {
filterList.addAll(this.getCallerFilters(phones));
}
Date[] dates = ((FilterDatePage) this.m_pages[2]).getResult();
if (dates != null && dates.length > 0) {
filterList.add(this.getDateFilter(dates));
}
IMsn msn = ((FilterMsnPage) this.m_pages[0]).getResult();
if (msn != null) {
if (!msn.getMSN().equalsIgnoreCase("*"))
filterList.add(new MsnFilter(new IMsn[] { msn }));
}
int limit = ((FilterItemCountPage) this.m_pages[4]).getResult();
if (limit > 0) {
filterList.add(new ItemCountFilter(limit));
}
IAttributeMap m = ((FilterCallTypePage) this.m_pages[5]).getResult();
if (m != null && m.size() > 0) {
filterList.add(new AttributeFilter(m));
}
ICip cip = ((FilterCipPage) this.m_pages[1]).getResult();
if (cip != null)
if (!cip.getCIP().equalsIgnoreCase("*"))
filterList.add(new CipFilter(cip));
this.m_filters = new IFilter[filterList.size()];
for (int i = 0; i < filterList.size(); i++) {
this.m_filters[i] = (IFilter) filterList.get(i);
}
String name = ((FilterNamePage) this.m_pages[6]).getResult();
IFilterManager fm = new JournalFilterManager();
if (name != null && name.trim().length() > 0) {
this.getRuntime().getConfigManagerFactory().getConfigManager().setProperty(Journal.NAMESPACE, "filtername_" + fm.getFiltersToString(getResult()), name);
this.getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
} else {
this.getRuntime().getConfigManagerFactory().getConfigManager().removeProperty(Journal.NAMESPACE, "filtername_" + fm.getFiltersToString(getResult()));
this.getRuntime().getConfigManagerFactory().getConfigManager().saveConfiguration();
}
return true;
}
this.m_filters = null;
return false;
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class GeoCoding method renderAsText.
public String renderAsText() {
if (this.m_o != null) {
if (this.m_o instanceof ICall) {
this.m_o = ((ICall) this.m_o).getCaller();
}
if (this.m_o instanceof ICaller) {
IAttributeMap m = ((ICaller) (this.m_o)).getAttributes();
if (m.contains(IJAMConst.ATTRIBUTE_NAME_GEO_LAT) && m.contains(IJAMConst.ATTRIBUTE_NAME_GEO_LNG)) {
StringBuffer co = new StringBuffer();
co.append(getLatitute(m.get(IJAMConst.ATTRIBUTE_NAME_GEO_LAT).getValue()));
co.append(", ");
co.append(getLongitute(m.get(IJAMConst.ATTRIBUTE_NAME_GEO_LNG).getValue()));
return co.toString();
}
}
}
return "";
}
Aggregations