package io.skysail.server.app.livingspec.userstory.resources;

import io.skysail.api.responses.SkysailResponse;
import io.skysail.server.restlet.resources.PutEntityServerResource;

import java.util.Date;
import org.restlet.resource.ResourceException;
import io.skysail.server.app.livingspec.*;
import io.skysail.server.app.livingspec.userstory.*;

/**
 * generated from putResource.stg
 */
public class PutUserStoryResourceGen extends PutEntityServerResource<io.skysail.server.app.livingspec.userstory.UserStory> {


    protected String id;
    protected LivingSpecApplication app;

    @Override
    protected void doInit() throws ResourceException {
        id = getAttribute("id");
        app = (LivingSpecApplication)getApplication();
    }

    @Override
    public void updateEntity(UserStory  entity) {
        io.skysail.server.app.livingspec.userstory.UserStory original = getEntity();
        copyProperties(original,entity);

        app.getRepository(io.skysail.server.app.livingspec.userstory.UserStory.class).update(original,app.getApplicationModel());
    }

    @Override
    public io.skysail.server.app.livingspec.userstory.UserStory getEntity() {
        return (io.skysail.server.app.livingspec.userstory.UserStory)app.getRepository(io.skysail.server.app.livingspec.userstory.UserStory.class).findOne(id);
    }

    @Override
    public String redirectTo() {
        return super.redirectTo(UserStorysResourceGen.class);
    }
}