@Override
  public void readFromTask(Task task) {
    this.myTask = task;
    Metadata metadata = ProducteevDataService.getInstance().getTaskMetadata(myTask.getId());
    if (metadata == null) metadata = ProducteevTask.newMetadata();

    // Fill the dashboard-spinner and set the current dashboard
    long dashboardId = ProducteevUtilities.INSTANCE.getDefaultDashboard();
    if (metadata.containsNonNullValue(ProducteevTask.DASHBOARD_ID))
      dashboardId = metadata.getValue(ProducteevTask.DASHBOARD_ID);

    StoreObject[] dashboardsData = ProducteevDataService.getInstance().getDashboards();
    dashboards = new ArrayList<ProducteevDashboard>(dashboardsData.length);
    ProducteevDashboard ownerDashboard = null;
    int dashboardSpinnerIndex = -1;

    int i = 0;
    for (i = 0; i < dashboardsData.length; i++) {
      ProducteevDashboard dashboard = new ProducteevDashboard(dashboardsData[i]);
      dashboards.add(dashboard);
      if (dashboard.getId() == dashboardId) {
        ownerDashboard = dashboard;
        dashboardSpinnerIndex = i;
      }
    }

    // dashboard to not sync as first spinner-entry
    dashboards.add(
        0,
        new ProducteevDashboard(
            ProducteevUtilities.DASHBOARD_NO_SYNC,
            activity.getString(R.string.producteev_no_dashboard),
            null));
    // dummy entry for adding a new dashboard
    dashboards.add(
        new ProducteevDashboard(
            ProducteevUtilities.DASHBOARD_CREATE,
            activity.getString(R.string.producteev_create_dashboard),
            null));

    ArrayAdapter<ProducteevDashboard> dashAdapter =
        new ArrayAdapter<ProducteevDashboard>(
            activity, android.R.layout.simple_spinner_item, dashboards);
    dashAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    dashboardSelector.setAdapter(dashAdapter);
    dashboardSelector.setSelection(dashboardSpinnerIndex + 1);

    if (ownerDashboard == null
        || ownerDashboard.getId() == ProducteevUtilities.DASHBOARD_NO_SYNC
        || ownerDashboard.getId() == ProducteevUtilities.DASHBOARD_CREATE) {
      responsibleSelector.setEnabled(false);
      responsibleSelector.setAdapter(null);
      view.findViewById(R.id.producteev_TEA_task_assign_label).setVisibility(View.GONE);
      return;
    }

    refreshResponsibleSpinner(ownerDashboard.getUsers());
  }
  @Override
  public String writeToModel(Task task) {
    Metadata metadata = ProducteevDataService.getInstance().getTaskMetadata(task.getId());
    try {
      if (metadata == null) {
        metadata = new Metadata();
        metadata.setValue(Metadata.KEY, ProducteevTask.METADATA_KEY);
        metadata.setValue(Metadata.TASK, task.getId());
        metadata.setValue(ProducteevTask.ID, 0L);
      }

      ProducteevDashboard dashboard = (ProducteevDashboard) dashboardSelector.getSelectedItem();
      metadata.setValue(ProducteevTask.DASHBOARD_ID, dashboard.getId());

      ProducteevUser responsibleUser = (ProducteevUser) responsibleSelector.getSelectedItem();

      if (responsibleUser == null) metadata.setValue(ProducteevTask.RESPONSIBLE_ID, 0L);
      else metadata.setValue(ProducteevTask.RESPONSIBLE_ID, responsibleUser.getId());

      // Erase PDTV-repeating-info if task itself is repeating with Astrid-repeat
      if (task.containsNonNullValue(Task.RECURRENCE)
          && task.getValue(Task.RECURRENCE).length() > 0) {
        metadata.setValue(ProducteevTask.REPEATING_SETTING, "");
      }

      if (metadata.getSetValues().size() > 0) {
        metadataService.save(metadata);
        task.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
      }
    } catch (Exception e) {
      Log.e("error-saving-pdv", "Error Saving Metadata", e); // $NON-NLS-1$ //$NON-NLS-2$
    }
    return null;
  }
 /**
  * Refresh the content of the responsibleSelector with the given userlist.
  *
  * @param newUsers the new userlist to show in the responsibleSelector
  */
 private void refreshResponsibleSpinner(ArrayList<ProducteevUser> newUsers) {
   Metadata metadata = ProducteevDataService.getInstance().getTaskMetadata(myTask.getId());
   long responsibleId = -1;
   if (metadata != null && metadata.containsNonNullValue(ProducteevTask.RESPONSIBLE_ID))
     responsibleId = metadata.getValue(ProducteevTask.RESPONSIBLE_ID);
   refreshResponsibleSpinner(newUsers, responsibleId);
 }
  @Override
  public void onReceive(Context context, Intent intent) {
    ContextManager.setContext(context);
    // if we aren't logged in, don't expose features
    if (!ProducteevUtilities.INSTANCE.isLoggedIn()) return;

    StoreObject[] dashboards = ProducteevDataService.getInstance().getDashboards();

    // If user does not have any dashboards, don't show this section at all
    if (dashboards.length == 0) return;

    FilterListHeader producteevHeader =
        new FilterListHeader(context.getString(R.string.producteev_FEx_header));

    long currentUserId = Preferences.getLong(ProducteevUtilities.PREF_USER_ID, -1);

    // load dashboards
    Filter[] dashboardFilters = new Filter[dashboards.length];
    for (int i = 0; i < dashboards.length; i++)
      dashboardFilters[i] =
          filterFromList(context, new ProducteevDashboard(dashboards[i]), currentUserId);
    FilterCategory producteevDashboards =
        new FilterCategory(context.getString(R.string.producteev_FEx_dashboard), dashboardFilters);

    // load responsible people, assigned by me
    TreeSet<ProducteevUser> people = loadResponsiblePeople(dashboards);
    Filter[] peopleByMeFilters = new Filter[people.size()];
    int index = 0;
    for (ProducteevUser person : people)
      peopleByMeFilters[index++] = filterUserAssignedByMe(context, person, currentUserId);
    FilterCategory producteevUsersByMeCategory =
        new FilterCategory(
            context.getString(R.string.producteev_FEx_responsible_byme), peopleByMeFilters);

    // load responsible people, assigned by others
    Filter[] peopleByOthersFilters = new Filter[people.size()];
    index = 0;
    for (ProducteevUser person : people)
      peopleByOthersFilters[index++] = filterUserAssignedByOthers(context, person, currentUserId);
    FilterCategory producteevUsersByOthersCategory =
        new FilterCategory(
            context.getString(R.string.producteev_FEx_responsible_byothers), peopleByOthersFilters);

    // transmit filter list
    FilterListItem[] list = new FilterListItem[4];
    list[0] = producteevHeader;
    list[1] = producteevDashboards;
    list[2] = producteevUsersByMeCategory;
    list[3] = producteevUsersByOthersCategory;
    Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_SEND_FILTERS);
    broadcastIntent.putExtra(AstridApiConstants.EXTRAS_ADDON, ProducteevUtilities.IDENTIFIER);
    broadcastIntent.putExtra(AstridApiConstants.EXTRAS_RESPONSE, list);
    context.sendBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
  }