com.raizlabs.android.dbflow.sql.builder.Condition Java Examples

The following examples show how to use com.raizlabs.android.dbflow.sql.builder.Condition. 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: InterpretationCreateFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    ButterKnife.bind(this, view);

    long dashboardItemId = getArguments().getLong(DashboardItem$Table.ID);
    mDashboardItem = new Select()
            .from(DashboardItem.class)
            .where(Condition.column(DashboardItem$Table
                    .ID).is(dashboardItemId))
            .querySingle();

    List<DashboardElement> elements = new Select()
            .from(DashboardElement.class)
            .where(Condition.column(DashboardElement$Table
                    .DASHBOARDITEM_DASHBOARDITEM).is(dashboardItemId))
            .and(Condition.column(DashboardElement$Table
                    .STATE).isNot(State.TO_DELETE.toString()))
            .queryList();

    mDashboardItem.setDashboardElements(elements);
    mDialogLabel.setText(getString(R.string.create_interpretation));
}
 
Example #2
Source File: DashboardController.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void sendDashboardElements() throws APIException {
    List<DashboardElement> elements = new Select()
            .from(DashboardElement.class)
            .where(Condition.column(DashboardElement$Table
                    .STATE).isNot(State.SYNCED))
            .orderBy(true, DashboardElement$Table.ID)
            .queryList();

    if (elements == null || elements.isEmpty()) {
        return;
    }

    for (DashboardElement element : elements) {
        switch (element.getState()) {
            case TO_POST: {
                postDashboardElement(element);
                break;
            }
            case TO_DELETE: {
                deleteDashboardElement(element);
                break;
            }
        }
    }
}
 
Example #3
Source File: DashboardController.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void sendDashboardItemChanges() throws APIException {
    List<DashboardItem> dashboardItems = new Select()
            .from(DashboardItem.class)
            .where(Condition.column(DashboardItem$Table
                    .STATE).isNot(State.SYNCED))
            .orderBy(true, DashboardItem$Table.ID)
            .queryList();

    if (dashboardItems == null || dashboardItems.isEmpty()) {
        return;
    }

    for (DashboardItem dashboardItem : dashboardItems) {
        switch (dashboardItem.getState()) {
            case TO_POST: {
                postDashboardItem(dashboardItem);
                break;
            }
            case TO_DELETE: {
                deleteDashboardItem(dashboardItem);
                break;
            }
        }
    }
}
 
Example #4
Source File: ImageRepository.java    From MoeGallery with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Observable<List<? extends Image>> loadListFromHistory() {
    return Observable.create(new Observable.OnSubscribe<List<? extends Image>>() {
        @Override
        public void call(Subscriber<? super List<? extends Image>> subscriber) {
            try {
                String providerUri = mSetting.provider().
                        replace(Providers.SCHEME_HTTPS, "").
                        replace(Providers.SCHEME_HTTP, "");

                List<HistoryImage> historyImages = new Select().from(HistoryImage.class).where(
                        Condition.column(HistoryImage$Table.PREVIEWURL)
                                .like("%" + providerUri + "%")).
                        orderBy(false, HistoryImage$Table.LAST).queryList();
                for (Image image : historyImages) {
                    mImageList.add(image);
                }
                subscriber.onNext(mImageList);
                notifyDataSetChanged();
            } catch (Exception e) {
                e.printStackTrace();
                subscriber.onError(e);
            }
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
 
Example #5
Source File: MainActivity.java    From MoeGallery with GNU General Public License v3.0 6 votes vote down vote up
void switchFavorite() {
    Image image = currentImage;
    List<FavoriteImage> favoriteImages = new Select().from(FavoriteImage.class).where(
            Condition.column(FavoriteImage$Table.PREVIEWURL).eq(image.getPreviewUrl())).
            queryList();

    if (favoriteImages.size() == 1) {
        favoriteImages.get(0).delete();
        menuFavorite.setTitle(R.string.add_favorite);
        floatFavorite.setDrawableIcon(getResources().getDrawable(
                R.drawable.ic_favorite_border_white_48dp));
    } else {
        new FavoriteImage(image).save();
        menuFavorite.setTitle(R.string.remove_favorite);
        floatFavorite.setDrawableIcon(getResources().getDrawable(
                R.drawable.ic_favorite_white_48dp));
    }
}
 
Example #6
Source File: ContentDatabaseCache.java    From iview-android-tv with MIT License 6 votes vote down vote up
private List<EpisodeBaseModel> getModelsOfType(Class<?> model, String type, List<EpisodeBaseModel> existing, boolean uniqueSeries) {
    FlowCursorList<EpisodeBaseModel> cursor = new FlowCursorList<>(false, EpisodeBaseModel.class,
            Condition.column(EpisodeBaseModel$Table.DATA_TYPE).eq(type));
    Map<String, EpisodeBaseModel> all = new HashMap<>();
    for (int i = 0, k = cursor.getCount(); i < k; i++) {
        EpisodeBaseModel ep = (EpisodeBaseModel) createInstanceOf(model);
        if (ep != null) {
            int index = existing.indexOf(ep);
            if (index > -1) {
                ep = existing.get(index);
            } else {
                EpisodeBaseModel item = cursor.getItem(i);
                item.unserialize();
                ep.merge(item);
            }
            if (uniqueSeries) {
                all.put(ep.getSeriesTitle(), ep);
            } else {
                all.put(ep.getHref(), ep);
            }
        }
    }
    cursor.close();
    return new ArrayList<>(all.values());
}
 
Example #7
Source File: AmiiboDescriptorCache.java    From amiibo with GNU General Public License v2.0 6 votes vote down vote up
@NonNull
@Override
protected AmiiboDescriptor updateInDatabaseInternal(@NonNull AmiiboDescriptor object) {
    AmiiboDescriptor previous = new Select()
            .from(AmiiboDescriptor.class)
            .where(Condition.column(AmiiboDescriptor$Table.AMIIBO_IDENTIFIER)
                    .eq(object.amiibo_identifier.toLowerCase()))
            .querySingle();
    if (previous == null) {
        previous = object;
        object.insert();
    } else {
        previous.amiibo_identifier = object.amiibo_identifier.toLowerCase();
        previous.name = object.name;
        previous.update();
    }
    return previous;
}
 
Example #8
Source File: DashboardItemAddFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    long dashboardId = getArguments().getLong(Dashboard$Table.ID);
    mDashboard = new Select()
            .from(Dashboard.class)
            .where(Condition.column(Dashboard$Table
                    .ID).is(dashboardId))
            .querySingle();

    ButterKnife.bind(this, view);

    InputMethodManager imm = (InputMethodManager)
            getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(mFilter.getWindowToken(), 0);

    mAdapter = new DashboardItemSearchDialogAdapter(
            LayoutInflater.from(getActivity()));
    mListView.setAdapter(mAdapter);
    mDialogLabel.setText(getString(R.string.add_dashboard_item));

    mResourcesMenu = new PopupMenu(getActivity(),mFilter, Gravity.END);
    mResourcesMenu.inflate(R.menu.menu_filter_resources);
    mResourcesMenu.setOnMenuItemClickListener(this);
}
 
Example #9
Source File: DashboardManageFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mDashboard = new Select()
            .from(Dashboard.class)
            .where(Condition.column(Dashboard$Table
                    .ID).is(getArguments().getLong(Dashboard$Table.ID)))
            .querySingle();

    ButterKnife.bind(this, view);

    mDialogLabel.setText(getString(R.string.manage_dashboard));
    mActionName.setText(getString(R.string.edit_name));

    mDashboardName.setText(mDashboard.getDisplayName());
    mDeleteButton.setEnabled(mDashboard.getAccess().isDelete());

    setFragmentBarActionMode(false);
    //// FIXME: 22/03/2018 The api 29 => putDashboard api call override the server dashboard.
    //// But the dashboard app is incomplete.
    //// The dashboard needs all the fields and children fields before put dashboards in api 29 =>
    if(SystemInfo.isLoggedInServerWithLatestApiVersion()){
        mDashboardName.setEnabled(false);
    }
}
 
Example #10
Source File: DashboardItem.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@JsonIgnore
public List<DashboardElement> queryRelatedDashboardElements() {
    if (isEmpty(getType())) {
        return new ArrayList<>();
    }

    List<DashboardElement> elements = new Select().from(DashboardElement.class)
            .where(Condition.column(DashboardElement$Table.DASHBOARDITEM_DASHBOARDITEM).is(getId()))
            .and(Condition.column(DashboardElement$Table.STATE).isNot(State.TO_DELETE.toString()))
            .queryList();

    if (elements == null) {
        elements = new ArrayList<>();
    }

    return elements;
}
 
Example #11
Source File: InterpretationContainerFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Boolean query(Context context) {
    List<Interpretation> interpretations = new Select()
            .from(Interpretation.class)
            .where(Condition.column(Interpretation$Table
                    .STATE).isNot(State.TO_DELETE.toString()))
            .queryList();

    return interpretations != null && interpretations.size() > 0;
}
 
Example #12
Source File: InterpretationCommentEditFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    ButterKnife.bind(this, view);

    mInterpretationComment = new Select()
            .from(InterpretationComment.class)
            .where(Condition.column(InterpretationComment$Table
                    .ID).is(getArguments().getLong(InterpretationComment$Table.ID)))
            .querySingle();

    mDialogLabel.setText(getString(R.string.edit_comment));
    mCommentEditText.setText(mInterpretationComment.getText());
}
 
Example #13
Source File: InterpretationTextFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    ButterKnife.bind(this, view);

    mInterpretation = new Select()
            .from(Interpretation.class)
            .where(Condition.column(Interpretation$Table
                    .ID).is(getArguments().getLong(Interpretation$Table.ID)))
            .querySingle();

    mDialogLabel.setText(getString(R.string.interpretation_text));
    mInterpretationText.setText(mInterpretation.getText());
}
 
Example #14
Source File: InterpretationTextEditFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    ButterKnife.bind(this, view);

    mInterpretation = new Select()
            .from(Interpretation.class)
            .where(Condition.column(Interpretation$Table
                    .ID).is(getArguments().getLong(Interpretation$Table.ID)))
            .querySingle();

    mDialogLabel.setText(getString(R.string.interpretation_text));
    mInterpretationText.setText(mInterpretation.getText());
}
 
Example #15
Source File: InterpretationFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public List<Interpretation> query(Context context) {
    List<Interpretation> interpretations
            = new Select()
            .from(Interpretation.class)
            .where(Condition.column(Interpretation$Table
                    .STATE).isNot(State.TO_DELETE.toString()))
            .queryList();
    for (Interpretation interpretation : interpretations) {
        List<InterpretationElement> elements = new Select()
                .from(InterpretationElement.class)
                .where(Condition.column(InterpretationElement$Table
                        .INTERPRETATION_INTERPRETATION).is(interpretation.getId()))
                .queryList();
        List<InterpretationComment> comments = new Select()
                .from(InterpretationComment.class)
                .where(Condition.column(InterpretationComment$Table
                        .INTERPRETATION_INTERPRETATION).is(interpretation.getId()))
                .and(Condition.column(InterpretationComment$Table
                        .STATE).isNot(State.TO_DELETE.toString()))
                .queryList();
        interpretation.setInterpretationElements(elements);
        interpretation.setComments(comments);
    }

    // sort interpretations by created field in reverse order.
    Collections.sort(interpretations,
            Collections.reverseOrder(Interpretation.CREATED_COMPARATOR));
    return interpretations;
}
 
Example #16
Source File: InterpretationCreateFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@OnClick({R.id.close_dialog_button, R.id.cancel_interpretation_create, R.id.create_interpretation})
@SuppressWarnings("unused")
public void onButtonClicked(View view) {
    if (view.getId() == R.id.create_interpretation) {
        // read user
        UserAccount userAccount = UserAccount
                .getCurrentUserAccountFromDb();
        User user = new Select()
                .from(User.class)
                .where(Condition.column(User$Table
                        .UID).is(userAccount.getUId()))
                .querySingle();

        // create interpretation
        Interpretation interpretation = createInterpretation(mDashboardItem,
                user, mInterpretationText.getText().toString());
        List<InterpretationElement> elements = interpretation
                .getInterpretationElements();

        // save interpretation
        interpretation.save();
        if (elements != null && !elements.isEmpty()) {
            for (InterpretationElement element : elements) {
                // save corresponding interpretation elements
                element.save();
            }
        }

        if (isDhisServiceBound()) {
            getDhisService().syncInterpretations(SyncStrategy.DOWNLOAD_ONLY_NEW);
            EventBusProvider.post(new UiEvent(UiEvent.UiEventType.SYNC_INTERPRETATIONS));
        }

        Toast.makeText(getActivity(),
                getString(R.string.successfully_created_interpretation), Toast.LENGTH_SHORT).show();
    }
    dismiss();
}
 
Example #17
Source File: ImageRepository.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Observable<List<? extends Image>> loadListFromFavorite() {
    return Observable.create(new Observable.OnSubscribe<List<? extends Image>>() {
        @Override
        public void call(Subscriber<? super List<? extends Image>> subscriber) {
            try {
                String providerUri = mSetting.provider().
                        replace(Providers.SCHEME_HTTPS, "").
                        replace(Providers.SCHEME_HTTP, "");

                List<FavoriteImage> favoriteImages = new Select().from(FavoriteImage.class)
                        .where(
                                Condition.column(FavoriteImage$Table.PREVIEWURL)
                                        .like("%" + providerUri + "%"))
                        .
                                orderBy(false, FavoriteImage$Table.LAST)
                        .queryList();
                for (Image image : favoriteImages) {
                    mImageList.add(image);
                }
                subscriber.onNext(mImageList);
                notifyDataSetChanged();
            } catch (Exception e) {
                e.printStackTrace();
                subscriber.onError(e);
            }
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
 
Example #18
Source File: ImageFragment.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
private void saveImage(Image image) {
    List<HistoryImage> historyImages = new Select().from(HistoryImage.class)
            .where(
                    Condition.column(HistoryImage$Table.PREVIEWURL).eq(image.getPreviewUrl()))
            .queryList();

    if (historyImages.size() == 1) {
        historyImages.get(0).updateLast();
        historyImages.get(0).save();
    } else {
        HistoryImage historyImage = new HistoryImage(image);
        historyImage.save();
    }
}
 
Example #19
Source File: InterpretationCommentsFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public List<InterpretationComment> query(Context context) {
    List<InterpretationComment> comments = new Select()
            .from(InterpretationComment.class)
            .where(Condition.column(InterpretationComment$Table
                    .INTERPRETATION_INTERPRETATION).is(mInterpretationId))
            .and(Condition.column(InterpretationComment$Table
                    .STATE).isNot(State.TO_DELETE.toString()))
            .queryList();
    Collections.sort(comments, IdentifiableObject.CREATED_COMPARATOR);
    return comments;
}
 
Example #20
Source File: MainActivity.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
public void setMenu(boolean isMain) {
    menuSearch.setVisible(isMain && !mSetting.floatSearch());
    menuInfo.setVisible(!isMain);
    menuWallpaper.setVisible(!isMain);
    menuShare.setVisible(!isMain);
    menuDownload.setVisible(!isMain && !mSetting.autoDownload());

    menuFavorite.setVisible(!isMain && !mSetting.floatFavorite());

    if (!isMain) {
        List<FavoriteImage> favoriteImages = new Select().from(FavoriteImage.class).where(
                Condition.column(FavoriteImage$Table.PREVIEWURL)
                        .eq(currentImage.getPreviewUrl())).queryList();

        if (favoriteImages.size() == 1) {
            menuFavorite.setTitle(R.string.remove_favorite);
            favoriteImages.get(0).updateLast();
            favoriteImages.get(0).save();
            floatFavorite.setDrawableIcon(getResources().getDrawable(
                    R.drawable.ic_favorite_white_48dp));
        } else {
            menuFavorite.setTitle(R.string.add_favorite);
            floatFavorite.setDrawableIcon(getResources().getDrawable(
                    R.drawable.ic_favorite_border_white_48dp));
        }
    }

}
 
Example #21
Source File: ContentDatabaseCache.java    From iview-android-tv with MIT License 5 votes vote down vote up
private LinkedHashMap<String, List<EpisodeBaseModel>> getCollections(Class<?> model, List<EpisodeBaseModel> existing) {
    LinkedHashMap<String, List<EpisodeBaseModel>> collections = new LinkedHashMap<>();
    FlowCursorList<EpisodeBaseModel> cursor = new FlowCursorList<>(false,
            (new Select()).from(EpisodeBaseModel.class)
                    .where(Condition.column(EpisodeBaseModel$Table.DATA_TYPE).eq(TYPE_COLLECTIONS))
                    .orderBy(true, EpisodeBaseModel$Table.DATA_COLLECTION_INDEX));
    for (int i = 0, k = cursor.getCount(); i < k; i++) {
        EpisodeBaseModel item = cursor.getItem(i);
        item.unserialize();
        int index = existing.indexOf(item);
        EpisodeBaseModel ep;
        if (index > -1) {
            ep = existing.get(index);
        } else {
            ep = (EpisodeBaseModel) createInstanceOf(model);
            if (ep != null) {
                ep.merge(item);
            }
        }
        if (ep != null) {
            if (!collections.containsKey(item.DATA_COLLECTION_KEY)) {
                collections.put(item.DATA_COLLECTION_KEY, new ArrayList<EpisodeBaseModel>());
            }
            collections.get(item.DATA_COLLECTION_KEY).add(ep);
        }
    }
    for (Map.Entry<String, List<EpisodeBaseModel>> collection : collections.entrySet()) {
        Log.d(TAG, "Loaded collection: " + collection.getKey() + " => " + collection.getValue().size());
    }
    return collections;
}
 
Example #22
Source File: AmiiboDescriptorCache.java    From amiibo with GNU General Public License v2.0 5 votes vote down vote up
@Override
@Nullable
protected AmiiboDescriptor getFromKeyInternal(@NonNull String identifier) {
    AmiiboDescriptor descriptor = null;
    identifier = identifier.toLowerCase();
    descriptor = new Select()
            .from(AmiiboDescriptor.class)
            .where(Condition.column(AmiiboDescriptor$Table.AMIIBO_IDENTIFIER).eq(identifier))
            .querySingle();
    return descriptor;
}
 
Example #23
Source File: AmiiboCache.java    From amiibo with GNU General Public License v2.0 5 votes vote down vote up
public List<Amiibo> getAmiibosUnsynced() {
    List<Amiibo> amiibos = new Select()
            .from(Amiibo.class)
            .where(Condition.CombinedCondition
                    .begin(Condition.column(Amiibo$Table.SYNCED).eq(false))
                    .or(Condition.column(Amiibo$Table.SYNCED).isNull()))
            .queryList();

    for (Amiibo amiibo : amiibos) updateCache(amiibo, true);

    return amiibos;
}
 
Example #24
Source File: AmiiboCache.java    From amiibo with GNU General Public License v2.0 5 votes vote down vote up
@NonNull
public List<Amiibo> getAmiibos(String amiibo_identifier) {
    amiibo_identifier = amiibo_identifier.toLowerCase();
    List<Amiibo> amiibos = new Select()
            .from(Amiibo.class)
            .where(Condition.column(Amiibo$Table.AMIIBO_IDENTIFIER).eq(amiibo_identifier))
            .orderBy(false, Amiibo$Table.CREATED_AT)
            .queryList();

    for (Amiibo amiibo : amiibos) updateCache(amiibo, true);

    return amiibos;
}
 
Example #25
Source File: AmiiboCache.java    From amiibo with GNU General Public License v2.0 5 votes vote down vote up
@NonNull
public Amiibo getAmiibo(String amiibo_uuid) {
    amiibo_uuid = amiibo_uuid.toLowerCase();
    Amiibo amiibo = new Select()
            .from(Amiibo.class)
            .where(Condition.column(Amiibo$Table.UUID).eq(amiibo_uuid))
            .querySingle();

    if (amiibo != null)
        updateCache(amiibo, true);

    return amiibo;
}
 
Example #26
Source File: AmiiboCache.java    From amiibo with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
@Override
protected Amiibo getFromKeyInternal(@NonNull Long id) {
    return new Select()
            .from(Amiibo.class)
            .where(Condition.column(Amiibo$Table.ID).eq(id))
            .querySingle();
}
 
Example #27
Source File: PostModel.java    From dev-summit-architecture-demo with Apache License 2.0 5 votes vote down vote up
@Nullable
public synchronized Post loadByClientIdAndUserId(String clientId, long userId) {
    if (StringUtils.isEmpty(clientId)) {
        return null;
    }
    return new Select().from(Post.class)
            .where(Condition.column(Post$Table.MCLIENTID).eq(clientId))
            .and(Condition.column(Post$Table.MUSERID).eq(userId))
            .querySingle();
}
 
Example #28
Source File: DashboardController.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static List<DashboardItem> queryDashboardItems(Dashboard dashboard) {
    Where<DashboardItem> where = new Select().from(DashboardItem.class)
            .where(Condition.column(DashboardItem$Table
                    .STATE).isNot(State.TO_POST));
    if (dashboard != null) {
        where = where.and(Condition.column(DashboardItem$Table
                .DASHBOARD_DASHBOARD).is(dashboard.getId()));
    }

    return where.queryList();
}
 
Example #29
Source File: DashboardItem.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Returns related to item DashboardElements.
 *
 * @return list of dashboard elements
 */
@JsonIgnore
public long getContentCount() {
    List<DashboardElement> elements = new Select().from(DashboardElement.class)
            .where(Condition.column(DashboardElement$Table.DASHBOARDITEM_DASHBOARDITEM).is(getId()))
            .and(Condition.column(DashboardElement$Table.STATE).isNot(State.TO_DELETE.toString()))
            .queryList();
    return elements == null ? 0 : elements.size();
}
 
Example #30
Source File: Dashboard.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Returns list of DashboardItems associated with dashboard.
 * NOTE! Items will be read from database.
 *
 * @return list of items.
 */
@JsonIgnore
public List<DashboardItem> queryRelatedDashboardItems() {
    return new Select().from(DashboardItem.class)
            .where(Condition.column(DashboardItem$Table
                    .DASHBOARD_DASHBOARD).is(getId()))
            .and(Condition.column(DashboardItem$Table
                    .STATE).isNot(State.TO_DELETE.toString()))
            .queryList();
}