/** * Converts a Message to Sms. Overwrites old address and contact name (international format). * * @param message * @return */ protected Sms toSms(final Message message) { Sms sms = new Sms(); sms.setAddress(message.getContact().getAddressIntl()); sms.setBody(message.getBody()); sms.setContactName(message.getContact().getContactName()); sms.setDate(message.getDate().getTime()); // This validation already takes place while importing messages. /* if (message.getType() == Type.Received && message.getDateSent() != null) { sms.setDateSent(null); System.out.println("date information wrong."); } else if (message.getType() == Type.Sent) { sms.setDateSent(getTimeOrNull(message.getDateSent())); } else { System.out.println("help " + message); } */ sms.setDateSent(getTimeOrNull(message.getDateSent())); sms.setLocked((short) 0); // TODO check sms.setProtocol((short) message.getProtocol().getValue()); sms.setRead(message.getRead().shortValue()); sms.setReadableDate(sdf.format(message.getDate())); sms.setScToa("null"); sms.setServiceCenter(message.getServiceCenter()); sms.setStatus((byte) message.getStatus().getValue()); sms.setSubject(message.getSubject()); sms.setToa("null"); sms.setType((short) message.getType().getValue()); return sms; }
@Override public Sms toExternalMessage(Message message, boolean keepOriginals) { Sms sms = toSms(message); if (keepOriginals) { sms.setAddress(message.getOriginalAddress()); sms.setContactName(message.getOriginalContactName()); } return sms; }