package com.bloatit.framework;

import java.util.Date;

import com.bloatit.framework.right.OfferRight;
import com.bloatit.framework.right.RightManager.Action;
import com.bloatit.model.data.DaoKudosable;
import com.bloatit.model.data.DaoOffer;

public final class Offer extends Kudosable {

    private final DaoOffer dao;

    public Offer(final DaoOffer dao) {
        super();
        this.dao = dao;
    }

    public DaoOffer getDao() {
        return dao;
    }

    public Date getDateExpire() {
        return dao.getDateExpire();
    }

    public boolean canSetdatExpire() {
        return new OfferRight.DateExpire().canAccess(calculateRole(this), Action.WRITE);
    }

    public void setDateExpire(final Date dateExpire) {
        new OfferRight.DateExpire().tryAccess(calculateRole(this), Action.WRITE);
        dao.setDateExpire(dateExpire);
    }

    public Demand getDemand() {
        return Demand.create(dao.getDemand());
    }

    public Description getDescription() {
        return new Description(dao.getDescription());
    }

    @Override
    protected DaoKudosable getDaoKudosable() {
        return dao;
    }

}

@@ -152,16 +152,58 @@
 Action;%0A
+import com.bloatit.model.data.DaoComment;%0A
 import c
@@ -358,16 +358,173 @@
 r dao;%0A%0A
+    public static Offer create(final DaoOffer dao) %7B%0A        if (dao == null) %7B%0A            return null;%0A        %7D%0A        return new Offer(dao);%0A    %7D%0A    %0A
     publ

add static create in Offer to init a Offer form a potentially null DaoOffer.