

package gov.va.med.cds.template;


import gov.va.med.cds.clinicaldata.TemplateMetaDataInterface;
import gov.va.med.cds.xml.schema.SchemaHelperInterface;

import java.util.Calendar;


public class TemplateCacheModelData
    implements
        TemplateCacheModelInterface
{
    private SchemaHelperInterface schemaHelper = null;
    private TemplateMetaDataInterface templateMetaData = null;
    long loadedIntoCache = -1;


    public String getTemplateId( )
    {
        String templateId = templateMetaData.getTemplateId();

        return templateId;
    }


    /*
     * (non-Javadoc)
     * 
     * @see gov.va.med.cds.template.TemplateCacheModelInterface#getMetaData()
     */
    public TemplateMetaDataInterface getTemplateMetaData( )
    {
        return templateMetaData;
    }


    /*
     * (non-Javadoc)
     * 
     * @see gov.va.med.cds.template.TemplateCacheModelInterface#setMetaData(gov.va.med.cds.cdm.clinicaldata.TemplateMetaDataInterface)
     */
    public void setTemplateMetaData( TemplateMetaDataInterface aTemplateMetaData )
    {
        this.templateMetaData = aTemplateMetaData;
    }


    /*
     * (non-Javadoc)
     * 
     * @see gov.va.med.cds.template.TemplateCacheModelInterface#getSchemaHelper()
     */
    public SchemaHelperInterface getSchemaHelper( )
    {
        return schemaHelper;
    }


    /*
     * (non-Javadoc)
     * 
     * @see gov.va.med.cds.template.TemplateCacheModelInterface#setSchemaHelper(gov.va.med.cds.xml.schema.SchemaHelperInterface)
     */
    public void setSchemaHelper( SchemaHelperInterface aSchemaHelper )
    {
        this.schemaHelper = aSchemaHelper;
    }


    public long getLoadedIntoCache( )
    {
        return loadedIntoCache;
    }


    public void setLoadedIntoCache( long loadedIntoCache )
    {
        this.loadedIntoCache = loadedIntoCache;
    }


    public long getTimeInCache( )
    {
        long currentTime = Calendar.getInstance().getTimeInMillis();
        long loadedIntoCache = getLoadedIntoCache();
        return ( currentTime - loadedIntoCache );
    }

    // public boolean hasAged( long aMaxAge )
    // {
    // boolean returnValue = false;
    // long currentTime = Calendar.getInstance().getTimeInMillis();
    // long loadedIntoCache = getLoadedIntoCache();
    // if ( currentTime - loadedIntoCache > aMaxAge )
    // {
    // returnValue = true;
    // }
    //          
    // return returnValue;
    // }

}
