All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.cq.screens.impl.aemio.ScreensChannelAssignmentModel Maven / Gradle / Ivy

/*************************************************************************
 *
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2016 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 ************************************************************************/
package com.adobe.cq.screens.impl.aemio;

import java.util.Calendar;
import java.util.Date;

import javax.inject.Inject;

import org.apache.commons.lang.time.DateUtils;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.Self;

import com.adobe.granite.haf.annotations.ApiLink;
import com.adobe.granite.haf.annotations.ApiModel;
import com.adobe.granite.haf.annotations.ApiProperty;


@Deprecated
@Model(adaptables = Resource.class)
@ApiModel(category = ScreensModelLookup.CATEGORY, type={"aem-io/screens/channelassignment"}, modelLookup = ScreensModelLookup.class)
public class ScreensChannelAssignmentModel {

    @Inject
    @Self
    protected Resource baseResource;

    @ApiLink(rel = "about")
    public String channel() {
        String url = ResourceUtil.getValueMap(baseResource).get("path", String.class);
        return url == null ? null : url + ".json";
    }

    @ApiProperty
    public String getRole() {
        return ResourceUtil.getValueMap(baseResource).get("role", String.class);
    }

    @ApiProperty
    public String getSchedule() {
        return ResourceUtil.getValueMap(baseResource).get("schedule", String.class);
    }

    @ApiProperty
    public long getStartDate() {
        Date date = ResourceUtil.getValueMap(baseResource).get("startDate", Date.class);
        return date != null ? DateUtils.truncate(date, Calendar.DATE).getTime() : 0;
    }

    @ApiProperty
    public long getEndDate() {
        Date date = ResourceUtil.getValueMap(baseResource).get("endDate", Date.class);
        return date != null ? DateUtils.addMilliseconds(DateUtils.ceiling(date, Calendar.DATE), -1).getTime() : 0;
    }

    @ApiProperty
    public long getPriority() {
        return ResourceUtil.getValueMap(baseResource).get("priority", 1L);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy