KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > entity > datasource > GenericHelper


1 /*
2  * Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included
12  * in all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  */

22
23 package org.ofbiz.entity.datasource;
24
25
26 import java.util.Collection JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Map JavaDoc;
29 import java.util.Set JavaDoc;
30
31 import org.ofbiz.entity.GenericEntityException;
32 import org.ofbiz.entity.GenericPK;
33 import org.ofbiz.entity.GenericValue;
34 import org.ofbiz.entity.condition.EntityCondition;
35 import org.ofbiz.entity.model.ModelEntity;
36 import org.ofbiz.entity.model.ModelRelation;
37 import org.ofbiz.entity.util.EntityFindOptions;
38 import org.ofbiz.entity.util.EntityListIterator;
39
40
41 /**
42  * Generic Entity Helper Class
43  *
44  *@author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
45  *@author <a HREF='mailto:chris_maurer@altavista.com'>Chris Maurer</a>
46  *@version $ revision: $
47  *@since 1.0
48  */

49 public interface GenericHelper {
50
51     /** Gets the name of the server configuration that corresponds to this helper
52      *@return server configuration name
53      */

54     public String JavaDoc getHelperName();
55
56     /** Creates a Entity in the form of a GenericValue and write it to the database
57      *@return GenericValue instance containing the new instance
58      */

59     public GenericValue create(GenericValue value) throws GenericEntityException;
60
61     /** Find a Generic Entity by its Primary Key
62      *@param primaryKey The primary key to find by.
63      *@return The GenericValue corresponding to the primaryKey
64      */

65     public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException;
66
67     /** Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names)
68      *@param primaryKey The primary key to find by.
69      *@param keys The keys, or names, of the values to retrieve; only these values will be retrieved
70      *@return The GenericValue corresponding to the primaryKey
71      */

72     public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set JavaDoc keys) throws GenericEntityException;
73
74     /** Find a number of Generic Value objects by their Primary Keys, all at once
75      *@param primaryKeys A List of primary keys to find by.
76      *@return List of GenericValue objects corresponding to the passed primaryKey objects
77      */

78     public List JavaDoc findAllByPrimaryKeys(List JavaDoc primaryKeys) throws GenericEntityException;
79
80     /** Remove a Generic Entity corresponding to the primaryKey
81      *@param primaryKey The primary key of the entity to remove.
82      *@return int representing number of rows effected by this operation
83      */

84     public int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException;
85
86     public List JavaDoc findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne,
87         ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List JavaDoc orderBy) throws GenericEntityException;
88
89     /** Finds GenericValues by the conditions specified in the EntityCondition object, the the EntityCondition javadoc for more details.
90      *@param modelEntity The ModelEntity of the Entity as defined in the entity XML file
91      *@param whereEntityCondition The EntityCondition object that specifies how to constrain this query before any groupings are done (if this is a view entity with group-by aliases)
92      *@param havingEntityCondition The EntityCondition object that specifies how to constrain this query after any groupings are done (if this is a view entity with group-by aliases)
93      *@param fieldsToSelect The fields of the named entity to get from the database; if empty or null all fields will be retreived
94      *@param orderBy The fields of the named entity to order the query by; optionally add a " ASC" for ascending or " DESC" for descending
95      *@param findOptions An instance of EntityFindOptions that specifies advanced query options. See the EntityFindOptions JavaDoc for more details.
96      *@return EntityListIterator representing the result of the query: NOTE THAT THIS MUST BE CLOSED WHEN YOU ARE
97      * DONE WITH IT, AND DON'T LEAVE IT OPEN TOO LONG BEACUSE IT WILL MAINTAIN A DATABASE CONNECTION.
98      */

99     public EntityListIterator findListIteratorByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition,
100         EntityCondition havingEntityCondition, Collection JavaDoc fieldsToSelect, List JavaDoc orderBy, EntityFindOptions findOptions)
101         throws GenericEntityException;
102
103     public long findCountByCondition(ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition) throws GenericEntityException;
104
105     /** Removes/deletes Generic Entity records found by all the specified condition
106      *@param modelEntity The ModelEntity of the Entity as defined in the entity XML file
107      *@param condition The condition that restricts the list of removed values
108      *@return int representing number of rows effected by this operation
109      */

110     public int removeByCondition(ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException;
111
112     /** Stores a group of values in a single query
113      *@param modelEntity The ModelEntity of the Entity as defined in the entity XML file
114      *@param fieldsToSet The fields of the named entity to set in the database
115      *@param condition The condition that restricts the list of updated values
116      *@return int representing number of rows effected by this operation
117      *@throws GenericEntityException
118      */

119     public int storeByCondition(ModelEntity modelEntity, Map JavaDoc fieldsToSet, EntityCondition condition) throws GenericEntityException;
120
121     /** Store the Entity from the GenericValue to the persistent store
122      *@param value GenericValue instance containing the entity
123      *@return int representing number of rows effected by this operation
124      */

125     public int store(GenericValue value) throws GenericEntityException;
126
127     /** Check the datasource to make sure the entity definitions are correct, optionally adding missing entities or fields on the server
128      *@param modelEntities Map of entityName names and ModelEntity values
129      *@param messages List to put any result messages in
130      *@param addMissing Flag indicating whether or not to add missing entities and fields on the server
131      */

132     public void checkDataSource(Map JavaDoc modelEntities, List JavaDoc messages, boolean addMissing) throws GenericEntityException;
133 }
134
Popular Tags