buildframework/helium/sf/java/metadata/src/com/nokia/helium/metadata/ORMFMPPLoader.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 588 c7c26511138f
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
 * All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
 * Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
 * Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
 * Description:  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
package com.nokia.helium.metadata;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
import java.io.File;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
import java.util.List;
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    21
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    22
import com.nokia.helium.metadata.fmpp.ORMQueryModeModel;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    23
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import fmpp.Engine;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import fmpp.tdd.DataLoader;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
/**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    29
 * Utility class to access the data from the database and used by FMPP templates.
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
public class ORMFMPPLoader implements DataLoader {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
    //private ResultSet rs;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
    /**
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    35
     * Return a object abstracting the access to a database.
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
     * @see fmpp.tdd.DataLoader#load(fmpp.Engine, java.util.List)
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
     */
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    38
    @SuppressWarnings("unchecked")
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
    public Object load(Engine engine, List args) throws Exception {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        //log.debug("args.size:" + args.size());
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    41
        if (args.size() < 1) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    42
            throw new MetadataException("The database path should be provided to load into FMPP.");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    43
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 588
diff changeset
    44
        ORMQueryModeModel model = new ORMQueryModeModel(new File((String)args.get(0)));
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        engine.setAttribute(this.getClass().toString(), model);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        return model;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
}