buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/fmpp/ORMQueryModel.java
changeset 628 7c4a911dc066
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
       
     1 /*
       
     2  * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved.
       
     4  * This component and the accompanying materials are made available
       
     5  * under the terms of the License "Eclipse Public License v1.0"
       
     6  * which accompanies this distribution, and is available
       
     7  * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8  *
       
     9  * Initial Contributors:
       
    10  * Nokia Corporation - initial contribution.
       
    11  *
       
    12  * Contributors:
       
    13  *
       
    14  * Description:  
       
    15  *
       
    16  */
       
    17 package com.nokia.helium.metadata.fmpp;
       
    18 
       
    19 import javax.persistence.EntityManager;
       
    20 
       
    21 import freemarker.template.TemplateCollectionModel;
       
    22 import freemarker.template.TemplateModelIterator;
       
    23 
       
    24 class ORMQueryModel implements TemplateCollectionModel {
       
    25 
       
    26     private String queryType;
       
    27     private String queryString;
       
    28     private String returnType;
       
    29     private EntityManager entityManager;
       
    30 
       
    31     public ORMQueryModel(EntityManager entityManager, String queryString,
       
    32             String type, String retType) {
       
    33         this.entityManager = entityManager;
       
    34         queryType = type;
       
    35         this.queryString = queryString;
       
    36         returnType = retType;
       
    37     }
       
    38 
       
    39     /*
       
    40      * Provides data via collection interface.
       
    41      * 
       
    42      * @return the iterator model from which the data is accessed.
       
    43      */
       
    44     public TemplateModelIterator iterator() {
       
    45         return new ORMTemplateModelIterator(entityManager, queryString,
       
    46                 queryType, returnType);
       
    47     }
       
    48 
       
    49 }