Java Code Examples for net.fortuna.ical4j.model.component.VEvent#getDescription()

The following examples show how to use net.fortuna.ical4j.model.component.VEvent#getDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EntityConverter.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * Merges calendar properties.
 * @param event The event.
 * @param note The note item.
 */
private void mergeCalendarProperties(VEvent event, NoteItem note) {
    //summary = displayName
    //description = body
    //uid = icalUid
    //dtstamp = clientModifiedDate/modifiedDate
    
    boolean isMod = note.getModifies()!=null;
    if (isMod) {
        ICalendarUtils.setUid(note.getModifies().getIcalUid(), event);
    }
    else {
        ICalendarUtils.setUid(note.getIcalUid(), event);
    }
    
    // inherited displayName and body should always be serialized
    if (event.getSummary() != null) {
        ICalendarUtils.setSummary(event.getSummary().getValue(), event);
    } else if (note.getDisplayName()==null && isMod) {
        ICalendarUtils.setSummary(note.getModifies().getDisplayName(), event);
    }
    else  {
        ICalendarUtils.setSummary(note.getDisplayName(), event);
    }
    if (event.getDescription() != null) {
        ICalendarUtils.setDescription(event.getDescription().getValue(), event);
    } else if (note.getBody()==null && isMod) {
        ICalendarUtils.setDescription(note.getModifies().getBody(), event);
    } else {
        ICalendarUtils.setDescription(note.getBody(), event);
    }
   
   
    if (note.getClientModifiedDate()!=null) {
        ICalendarUtils.setDtStamp(note.getClientModifiedDate(), event);
    }
    else {
        ICalendarUtils.setDtStamp(note.getModifiedDate(), event);
    }
    
    if (StampUtils.getTaskStamp(note) != null) {
        ICalendarUtils.setXProperty(X_OSAF_STARRED, "TRUE", event);
    }
    else {
        ICalendarUtils.setXProperty(X_OSAF_STARRED, null, event);
    }
}
 
Example 2
Source File: EntityConverter.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * Sets calendar attributes.
 * @param note The note item.
 * @param event The event.
 */
private void setCalendarAttributes(NoteItem note, VEvent event) {
    
    // UID (only set if master)
    if(event.getUid()!=null && note.getModifies()==null) {
        note.setIcalUid(event.getUid().getValue());
    }
    
    // for now displayName is limited to 1024 chars
    if (event.getSummary() != null) {
        note.setDisplayName(StringUtils.substring(event.getSummary()
                .getValue(), 0, 1024));
    }

    if (event.getDescription() != null) {
        note.setBody(event.getDescription().getValue());
    }

    // look for DTSTAMP
    if(event.getDateStamp()!=null) {
        note.setClientModifiedDate(event.getDateStamp().getDate());
    }
    
    // look for absolute VALARM
    VAlarm va = ICalendarUtils.getDisplayAlarm(event);
    if (va != null && va.getTrigger()!=null) {
        Trigger trigger = va.getTrigger();
        Date reminderTime = trigger.getDateTime();
        if (reminderTime != null) {
            note.setReminderTime(reminderTime);
        }
    }

    // calculate triage status based on start date
    java.util.Date now =java.util.Calendar.getInstance().getTime();
    Date eventStartDate = event.getStartDate() != null && event.getStartDate().getDate() != null 
    		? event.getStartDate().getDate()
    		:new Date();
    boolean later = eventStartDate.after(now);
    int code = later ? TriageStatus.CODE_LATER : TriageStatus.CODE_DONE;
    
    TriageStatus triageStatus = note.getTriageStatus();
    
    // initialize TriageStatus if not present
    if (triageStatus == null) {
        triageStatus = TriageStatusUtil.initialize(entityFactory
                .createTriageStatus());
        note.setTriageStatus(triageStatus);
    }

    triageStatus.setCode(code);
    
    // check for X-OSAF-STARRED
    if ("TRUE".equals(ICalendarUtils.getXProperty(X_OSAF_STARRED, event))) {
        TaskStamp ts = StampUtils.getTaskStamp(note);
        if (ts == null) {
            note.addStamp(entityFactory.createTaskStamp());
        }
    }
}
 
Example 3
Source File: MainActivity.java    From ICSImport with GNU General Public License v3.0 4 votes vote down vote up
@Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);

       Intent intent = getIntent();

Uri data = intent.getData();

try {
	//use ical4j to parse the event
	CalendarBuilder cb = new CalendarBuilder();
	Calendar calendar = null;
	calendar = cb.build(getStreamFromOtherSource(data));

	if (calendar != null) {

		Iterator i = calendar.getComponents(Component.VEVENT).iterator();

		while (i.hasNext()) {
			VEvent event = (VEvent) i.next();

			Intent insertIntent = new Intent(Intent.ACTION_INSERT)
				.setType("vnd.android.cursor.item/event");

			if (event.getStartDate() != null)
				insertIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, event.getStartDate().getDate().getTime());

			if (event.getEndDate() != null)
				insertIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, event.getEndDate().getDate().getTime());

			if (event.getSummary() != null)
				insertIntent.putExtra(CalendarContract.Events.TITLE, event.getSummary().getValue());

			if (event.getDescription() != null)
				insertIntent.putExtra(CalendarContract.Events.DESCRIPTION, event.getDescription().getValue());

			if (event.getLocation() != null) 
				insertIntent.putExtra(CalendarContract.Events.EVENT_LOCATION, event.getLocation().getValue());

			insertIntent.putExtra(CalendarContract.Events.ACCESS_LEVEL, CalendarContract.Events.ACCESS_PRIVATE);
			startActivity(insertIntent);

		}
	}

} catch (Exception e) {
	e.printStackTrace();
	Toast.makeText(getBaseContext(), "Invalid ICS file", Toast.LENGTH_LONG).show();
}
finish();

   }