use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class OutlookNumberType 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) {
this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
}
if (this.m_o instanceof ITreeItemCallerData) {
IAttributeMap m = ((ITreeItemCallerData) m_o).getAttributes();
IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
if (m.contains(IOutlookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber())) {
IAttribute type = m.get(IOutlookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber());
if (type != null) {
return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class PDFCallerListFilter method doExport.
public boolean doExport() {
Document document = new Document(PageSize.A4.rotate());
document.addCreationDate();
document.addCreator("jAnrufmonitor");
try {
PdfWriter.getInstance(document, new FileOutputStream(this.m_filename));
document.open();
// get renderers
List renderer = new ArrayList();
String renderer_config = this.getRuntime().getConfigManagerFactory().getConfigManager().getProperty("ui.jface.application.editor.Editor", "renderer");
if (renderer_config != null && renderer_config.length() > 0) {
StringTokenizer s = new StringTokenizer(renderer_config, ",");
while (s.hasMoreTokens()) {
renderer.add(RendererRegistry.getInstance().getRenderer(s.nextToken()));
}
}
// get column width
float totalWidth = 0;
String[] cWidth = new String[renderer.size()];
for (int i = 0, j = renderer.size(); i < j; i++) {
cWidth[i] = getRuntime().getConfigManagerFactory().getConfigManager().getProperty("ui.jface.application.editor.Editor", "col_size_" + ((ITableCellRenderer) renderer.get(i)).getID());
if (cWidth[i] != null && cWidth[i].length() > 0) {
totalWidth += Float.parseFloat(cWidth[i]);
}
if (cWidth[i] != null && cWidth[i].length() == 0) {
cWidth[i] = "0";
}
}
float[] widths = new float[renderer.size()];
for (int i = 0, j = renderer.size(); i < j; i++) {
widths[i] = Float.parseFloat(cWidth[i]) / totalWidth;
}
PdfPTable table = new PdfPTable(widths);
table.setHeaderRows(1);
table.setWidthPercentage(100f);
ITableCellRenderer t = null;
PdfPCell cell = null;
for (int i = 0, j = renderer.size(); i < j; i++) {
t = (ITableCellRenderer) renderer.get(i);
if (t == null) {
this.m_logger.severe("No renderer found for ID: " + (String) renderer.get(i));
this.m_logger.severe("Export to PDF format canceled...");
return false;
}
cell = new PdfPCell(new Paragraph(t.getHeader()));
cell.setBackgroundColor(new Color(0xC0, 0xC0, 0xC0));
table.addCell(cell);
}
ICaller c = null;
String cellContent = null;
Color iterateColor1 = new Color(0xDD, 0xDD, 0xDD);
Color iterateColor2 = new Color(0xFF, 0xFF, 0xFF);
cell = null;
int type_col = -1, num_col = -1;
for (int i = 0, j = this.m_callerList.size(); i < j; i++) {
c = this.m_callerList.get(i);
for (int k = 0, m = renderer.size(); k < m; k++) {
t = (ITableCellRenderer) renderer.get(k);
t.updateData(c);
// find number and typ column for multiline callers
if (t.getID().equalsIgnoreCase("NumberType"))
type_col = k;
if (t.getID().equalsIgnoreCase("Number"))
num_col = k;
cellContent = t.renderAsText();
if (cellContent != null && cellContent.length() > 0) {
cell = new PdfPCell(new Phrase(cellContent));
cell.setBackgroundColor((i % 2 == 0 ? iterateColor1 : iterateColor2));
table.addCell(cell);
} else {
cellContent = t.renderAsImageID();
if (cellContent != null && cellContent.length() > 0) {
if (cellContent.startsWith("db://")) {
InputStream in = ImageHandler.getInstance().getImageStream(c);
if (in != null) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
Stream.copy(in, out, true);
in.close();
out.close();
Image pdfImage = Image.getInstance(out.toByteArray());
// pdfImage.scaleAbsolute(90.0f, 45.0f);
table.addCell(pdfImage);
} else {
table.addCell(" ");
}
} else if (new File(cellContent).exists()) {
Image pdfImage = Image.getInstance(cellContent);
table.addCell(pdfImage);
} else {
Image pdfImage = Image.getInstance(SWTImageManager.getInstance(PIMRuntime.getInstance()).getImagePath(cellContent));
table.addCell(pdfImage);
}
// ((Image pdfImage = Image.getInstance(cellContent);
// cell = new PdfPCell(pdfImage);
// cell.setBackgroundColor((i%2==0 ? iterateColor1 : iterateColor2));
// table.addCell(pdfImage);
} else {
cell = new PdfPCell(new Phrase(" "));
cell.setBackgroundColor((i % 2 == 0 ? iterateColor1 : iterateColor2));
table.addCell(cell);
}
}
// last column reached check for multiline caller
if (k == m - 1 && (type_col > -1 || num_col > -1) && (c instanceof IMultiPhoneCaller) && (((IMultiPhoneCaller) c).getPhonenumbers().size() > 1)) {
List phones = ((IMultiPhoneCaller) c).getPhonenumbers();
IPhonenumber pn = null;
for (int y = 1, z = phones.size(); y < z; y++) {
pn = (IPhonenumber) phones.get(y);
for (int w = 0, x = renderer.size(); w < x; w++) {
t = (ITableCellRenderer) renderer.get(w);
if (t.getID().equalsIgnoreCase("NumberType") || t.getID().equalsIgnoreCase("Number")) {
if (t.getID().equalsIgnoreCase("NumberType")) {
final IPhonenumber lpn = pn;
final IAttributeMap lam = c.getAttributes();
t.updateData(new ITreeItemCallerData() {
public IAttributeMap getAttributes() {
return lam;
}
public IPhonenumber getPhone() {
return lpn;
}
});
} else
t.updateData(pn);
cellContent = t.renderAsText();
if (cellContent != null && cellContent.length() > 0) {
cell = new PdfPCell(new Phrase(cellContent));
cell.setBackgroundColor((i % 2 == 0 ? iterateColor1 : iterateColor2));
table.addCell(cell);
} else {
cell = new PdfPCell(new Phrase(" "));
cell.setBackgroundColor((i % 2 == 0 ? iterateColor1 : iterateColor2));
table.addCell(cell);
}
} else {
cell = new PdfPCell(new Phrase(" "));
cell.setBackgroundColor((i % 2 == 0 ? iterateColor1 : iterateColor2));
table.addCell(cell);
}
}
}
}
}
}
document.add(table);
} catch (DocumentException de) {
this.m_logger.severe(de.getMessage());
return false;
} catch (IOException ioe) {
this.m_logger.severe(ioe.getMessage());
return false;
} finally {
document.close();
}
return true;
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class Etiquet 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) {
this.m_o = new TreeItemCallerData(((ICaller) this.m_o).getAttributes(), ((ICaller) this.m_o).getPhoneNumber());
}
if (this.m_o instanceof ITreeItemCallerData) {
IAttributeMap m = ((ITreeItemCallerData) m_o).getAttributes();
IPhonenumber pn = ((ITreeItemCallerData) m_o).getPhone();
if (m.contains(IMacAddressBookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber())) {
IAttribute type = m.get(IMacAddressBookNumberMapping.MAPPING_ATTTRIBUTE_ID + pn.getTelephoneNumber());
if (type != null) {
return PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(NAMESPACE, type.getValue(), "label", getLanguage());
}
}
}
}
return "";
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class NcidCallRaw method toCall.
public ICall toCall() {
if (this.m_line == null || this.m_line.length() == 0)
return null;
if (this.m_call == null) {
IRuntime r = PIMRuntime.getInstance();
String[] call = this.m_line.split("\\*");
if (call.length >= 8 && (call[0].trim().equalsIgnoreCase("CID:") || call[0].trim().equalsIgnoreCase("CIDLOG:"))) {
// create MSN
IMsn msn = r.getCallFactory().createMsn(getFestnetzAlias(call[6]), "");
msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[8].trim());
// if no CLIR call, check internal
if (pn == null)
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[8].trim(), msn.getMSN());
// if no internal call, check regular
if (pn == null) {
// if incoming call does not start with 0, the Provider number seems to have the wrong format
// assume it is an international format 4971657110
boolean onlyNumbers = call[8].matches("[+-]?[0-9]+");
if (!call[8].startsWith("0") && onlyNumbers) {
call[8] = "00" + call[8];
}
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[8].trim(), msn.getMSN());
}
ICaller caller = r.getCallerFactory().createCaller(pn);
// create call data
// added 2009/05/01
String dateformat = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(NcidMonitor.NAMESPACE, "dateformat");
if (dateformat == null || dateformat.trim().length() == 0)
dateformat = "ddMMyyyyHHmm";
if (Logger.getLogger(IJAMConst.DEFAULT_LOGGER).isLoggable(Level.INFO))
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Setting date format to #" + dateformat + "#");
SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
Date date = new Date(0);
try {
date = sdf.parse(call[2] + call[4]);
} catch (ParseException e) {
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected. " + call[2] + call[4] + " does not match #" + dateformat + "#");
}
ICip cip = r.getCallFactory().createCip(getCip("sip"), "");
cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
// create attributes
IAttributeMap am = r.getCallFactory().createAttributeMap();
am.add(r.getCallFactory().createAttribute("ncid.key", call[6]));
if (call.length >= 12) {
am.add(r.getCallFactory().createAttribute("ncid.msg", call[10]));
am.add(r.getCallFactory().createAttribute("ncid.callername", call[12]));
}
am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_MISSED));
// create UUID
StringBuffer uuid = new StringBuffer();
uuid.append(date.getTime());
uuid.append("-");
uuid.append(pn.getTelephoneNumber());
uuid.append("-");
uuid.append(msn.getMSN());
// limit uuid to 32 chars
if (uuid.length() > 31) {
// reduce byte length to append -1 for redundant calls max -1-1 --> 3 calls
uuid = new StringBuffer(uuid.substring(0, 31));
}
this.m_call = r.getCallFactory().createCall(uuid.toString(), caller, msn, cip, date);
this.m_call.setAttributes(am);
}
if (call.length >= 8 && call[0].trim().equalsIgnoreCase("OUT:")) {
// create msn
IMsn msn = r.getCallFactory().createMsn(getFestnetzAlias(call[6]), "");
msn.setAdditional(r.getMsnManager().getMsnLabel(msn));
// create caller data
String callByCall = null;
IPhonenumber pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toClirPhonenumber(call[8].trim());
// if no CLIR call, check internal
if (pn == null)
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toInternalPhonenumber(call[8].trim(), msn.getMSN());
// if no internal call, check regular
if (pn == null) {
// added 2006/08/10: trim call-by-call information
// only can occure on state CALL (out-going calls)
callByCall = getCallByCall(call[8]);
if (callByCall != null) {
call[8] = call[8].substring(callByCall.length());
}
// requires addition of areacode
if (!call[8].startsWith("0")) {
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Assuming number " + call[8] + " has missing areacode.");
call[8] = this.getGeneralAreaCode() + call[8];
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Added areacode to number " + call[8]);
}
pn = PhonenumberAnalyzer.getInstance(PIMRuntime.getInstance()).toPhonenumber(call[8].trim(), msn.getMSN());
}
ICaller caller = r.getCallerFactory().createCaller(pn);
// create call data
// added 2009/05/27
String dateformat = PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(NcidMonitor.NAMESPACE, "dateformat");
if (dateformat == null || dateformat.trim().length() == 0)
dateformat = "ddMMyyyyHHmm";
if (Logger.getLogger(IJAMConst.DEFAULT_LOGGER).isLoggable(Level.INFO))
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).info("Setting date format to #" + dateformat + "#");
SimpleDateFormat sdf = new SimpleDateFormat(dateformat);
Date date = new Date(0);
try {
date = sdf.parse(call[2] + call[4]);
} catch (ParseException e) {
Logger.getLogger(IJAMConst.DEFAULT_LOGGER).severe("Wrong standard date format detected. " + call[2] + call[4] + " does not match #" + dateformat + "#");
}
ICip cip = r.getCallFactory().createCip(getCip("sip"), "");
cip.setAdditional(r.getCipManager().getCipLabel(cip, ""));
// create attributes
IAttributeMap am = r.getCallFactory().createAttributeMap();
am.add(r.getCallFactory().createAttribute("ncid.key", call[6]));
if (call.length >= 12) {
am.add(r.getCallFactory().createAttribute("ncid.msg", call[10]));
am.add(r.getCallFactory().createAttribute("ncid.callername", call[12]));
}
am.add(r.getCallFactory().createAttribute(IJAMConst.ATTRIBUTE_NAME_CALLSTATUS, IJAMConst.ATTRIBUTE_VALUE_OUTGOING));
if (callByCall != null)
am.add(r.getCallFactory().createAttribute("ncid.callbycall", callByCall));
// create UUID
StringBuffer uuid = new StringBuffer();
uuid.append(date.getTime());
uuid.append("-");
uuid.append(pn.getTelephoneNumber());
uuid.append("-");
uuid.append(msn.getMSN());
// limit uuid to 32 chars
if (uuid.length() > 31) {
// reduce byte length to append -1 for redundant calls max -1-1 --> 3 calls
uuid = new StringBuffer(uuid.substring(0, 31));
}
this.m_call = r.getCallFactory().createCall(uuid.toString(), caller, msn, cip, date);
this.m_call.setAttributes(am);
}
}
return this.m_call;
}
use of de.janrufmonitor.framework.IAttributeMap in project janrufmonitor by tbrandt77.
the class AbstractFilterManager method getFiltersToLabelText.
public String getFiltersToLabelText(IFilter[] f, int shorten) {
if (f != null && f.length > 0) {
boolean processedCaller = false;
StringBuffer sb = new StringBuffer();
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_limit", "label", this.getLanguage()));
for (int i = 0; i < f.length; i++) {
IFilter f1 = f[i];
if (f1.getType().equals(FilterType.CIP)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_cip", "label", this.getLanguage()));
sb.append(this.getRuntime().getCipManager().getCipLabel(((CipFilter) f1).getCip(), this.getLanguage()));
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.MSN)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_msn", "label", this.getLanguage()));
IMsn[] m = ((MsnFilter) f1).getMsn();
for (int k = 0, l = m.length; k < l; k++) {
sb.append(m[k].getMSN());
m[k].setAdditional(this.getRuntime().getMsnManager().getMsnLabel(m[k]));
if (m[k].getAdditional().length() > 0) {
sb.append(" (" + m[k].getAdditional() + ")");
}
if ((k + 1) < l)
sb.append(", ");
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.DATE)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
if (((DateFilter) f1).getTimeframe() == -1) {
Date d1 = ((DateFilter) f1).getDateFrom();
Date d2 = ((DateFilter) f1).getDateTo();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
sb.append("[");
sb.append(sdf.format(d2));
sb.append(" - ");
if (d1 != null)
sb.append(sdf.format(d1));
else {
sb.append(this.getI18nManager().getString(this.getNamespace(), "today", "label", this.getLanguage()));
}
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
} else {
sb.append("[");
sb.append(this.getI18nManager().getString(this.getNamespace(), Long.toString(((DateFilter) f1).getTimeframe()), "label", this.getLanguage()));
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
}
if (f1.getType().equals(FilterType.YEAR)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
sb.append("[");
sb.append(((YearFilter) f1).getYear());
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.MONTH_YEAR)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_date", "label", this.getLanguage()));
sb.append("[");
sb.append(((MonthYearFilter) f1).getYear());
sb.append(".");
sb.append((((MonthYearFilter) f1).getMonth() > 9 ? ((MonthYearFilter) f1).getMonth() : "0" + ((MonthYearFilter) f1).getMonth()));
sb.append("]");
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.CALLER) && !processedCaller) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_caller", "label", this.getLanguage()));
if ((i + 1) < f.length && !processedCaller)
sb.append(", ");
processedCaller = true;
}
if (f1.getType().equals(FilterType.PHONENUMBER)) {
PhonenumberFilter cf = ((PhonenumberFilter) f1);
IPhonenumber pnc = getRuntime().getCallerFactory().createPhonenumber(cf.getPhonenumber().getIntAreaCode(), cf.getPhonenumber().getAreaCode(), "0000000000");
ICaller c = Identifier.identifyDefault(getRuntime(), pnc);
if (c != null) {
IAttribute city = c.getAttribute(IJAMConst.ATTRIBUTE_NAME_CITY);
if (city != null && city.getValue().trim().length() > 0) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()).substring(2));
sb.append(city.getValue().trim());
sb.append(" (0");
sb.append(cf.getPhonenumber().getAreaCode());
sb.append(")");
if ((i + 1) < f.length)
sb.append(", ");
continue;
}
}
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_intarea", "label", this.getLanguage()));
sb.append("00" + cf.getPhonenumber().getIntAreaCode());
if (cf.getPhonenumber().getAreaCode().trim().length() > 0) {
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_area", "label", this.getLanguage()));
sb.append("0" + cf.getPhonenumber().getAreaCode().trim());
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.ITEMCOUNT)) {
ItemCountFilter cf = ((ItemCountFilter) f1);
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_itemcount", "label", this.getLanguage()));
sb.append(cf.getLimit());
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.ATTRIBUTE)) {
AttributeFilter cf = ((AttributeFilter) f1);
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_CALLSTATUS)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getValue(), "label", this.getLanguage()));
} else if (a.getName().equalsIgnoreCase(IJAMConst.ATTRIBUTE_NAME_CATEGORY)) {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
sb.append(a.getValue());
} else {
sb.append(this.getI18nManager().getString(this.getNamespace(), a.getName(), "label", this.getLanguage()));
}
if (it.hasNext())
sb.append(", ");
}
}
if ((i + 1) < f.length)
sb.append(", ");
}
if (f1.getType().equals(FilterType.CHARACTER)) {
CharacterFilter cf = ((CharacterFilter) f1);
sb.append(this.getI18nManager().getString(this.getNamespace(), "view_" + cf.getAttributeName(), "label", this.getLanguage()));
sb.append("[");
sb.append(cf.getCharacter().toUpperCase());
sb.append("...]");
if ((i + 1) < f.length)
sb.append(", ");
}
}
String s = sb.toString();
if (s.trim().endsWith(","))
s = s.trim().substring(0, s.trim().length() - 1);
if (shorten > -1 && shorten < s.length()) {
return s.substring(0, Math.min(shorten, s.length())) + "...";
}
if (s.trim().length() > 0)
return s;
}
return this.getI18nManager().getString(this.getNamespace(), "view_all", "label", this.getLanguage());
}
Aggregations