Search in sources :

Example 1 with SiteFavouriteTarget

use of org.alfresco.rest.api.tests.client.data.SiteFavouriteTarget in project alfresco-remote-api by Alfresco.

the class TestFavourites method makeSiteFavourite.

private Favourite makeSiteFavourite(Site site) throws ParseException {
    SiteFavouriteTarget target = new SiteFavouriteTarget(site);
    Date creationDate = new Date();
    Favourite favourite = new Favourite(creationDate, null, target, null);
    return favourite;
}
Also used : SiteFavouriteTarget(org.alfresco.rest.api.tests.client.data.SiteFavouriteTarget) Date(java.util.Date) Favourite(org.alfresco.rest.api.tests.client.data.Favourite)

Example 2 with SiteFavouriteTarget

use of org.alfresco.rest.api.tests.client.data.SiteFavouriteTarget in project alfresco-remote-api by Alfresco.

the class TestFavourites method filter.

/**
 * Returns a new list.
 *
 * @param favourites List<Favourite>
 * @param types Set<Type>
 * @return ArrayList<Favourite>
 */
private ArrayList<Favourite> filter(List<Favourite> favourites, final Set<Type> types) {
    Predicate<Favourite> predicate = new Predicate<Favourite>() {

        @Override
        public boolean apply(Favourite other) {
            Type type = null;
            if (other.getTarget() instanceof FileFavouriteTarget) {
                type = Type.FILE;
            } else if (other.getTarget() instanceof FolderFavouriteTarget) {
                type = Type.FOLDER;
            } else if (other.getTarget() instanceof SiteFavouriteTarget) {
                type = Type.SITE;
            }
            boolean ret = (type != null && types.contains(type));
            return ret;
        }
    };
    ArrayList<Favourite> ret = Lists.newArrayList(Collections2.filter(favourites, predicate));
    return ret;
}
Also used : Type(org.alfresco.service.cmr.favourites.FavouritesService.Type) FolderFavouriteTarget(org.alfresco.rest.api.tests.client.data.FolderFavouriteTarget) SiteFavouriteTarget(org.alfresco.rest.api.tests.client.data.SiteFavouriteTarget) FileFavouriteTarget(org.alfresco.rest.api.tests.client.data.FileFavouriteTarget) Favourite(org.alfresco.rest.api.tests.client.data.Favourite) Predicate(com.google.common.base.Predicate)

Aggregations

Favourite (org.alfresco.rest.api.tests.client.data.Favourite)2 SiteFavouriteTarget (org.alfresco.rest.api.tests.client.data.SiteFavouriteTarget)2 Predicate (com.google.common.base.Predicate)1 Date (java.util.Date)1 FileFavouriteTarget (org.alfresco.rest.api.tests.client.data.FileFavouriteTarget)1 FolderFavouriteTarget (org.alfresco.rest.api.tests.client.data.FolderFavouriteTarget)1 Type (org.alfresco.service.cmr.favourites.FavouritesService.Type)1