Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
FieldHome |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright (c) 2002-2017, Mairie de Paris | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright notice | |
10 | * and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright notice | |
13 | * and the following disclaimer in the documentation and/or other materials | |
14 | * provided with the distribution. | |
15 | * | |
16 | * 3. Neither the name of 'Mairie de Paris' nor 'Lutece' nor the names of its | |
17 | * contributors may be used to endorse or promote products derived from | |
18 | * this software without specific prior written permission. | |
19 | * | |
20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE | |
24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
30 | * POSSIBILITY OF SUCH DAMAGE. | |
31 | * | |
32 | * License 1.0 | |
33 | */ | |
34 | package fr.paris.lutece.plugins.adminsql.business; | |
35 | ||
36 | import fr.paris.lutece.portal.service.plugin.Plugin; | |
37 | import fr.paris.lutece.portal.service.spring.SpringContextService; | |
38 | import fr.paris.lutece.util.ReferenceList; | |
39 | ||
40 | import java.util.List; | |
41 | ||
42 | /** | |
43 | * The class calling the business objects | |
44 | */ | |
45 | 0 | public final class FieldHome |
46 | { | |
47 | 0 | private static IFieldDAO _dao = (IFieldDAO) SpringContextService.getPluginBean( "adminsql", "fieldDAO" ); |
48 | ||
49 | /** | |
50 | * Find the list of all fields of a table | |
51 | * @param strPoolName the name of the pool | |
52 | * @param strTableName the name of the table | |
53 | * @param plugin Plugin objet | |
54 | * @return list of all the fields | |
55 | */ | |
56 | public static List<Field> findAll( String strPoolName, String strTableName, Plugin plugin ) | |
57 | { | |
58 | 0 | return _dao.selectFieldList( strPoolName, strTableName, plugin ); |
59 | } | |
60 | ||
61 | /** | |
62 | * Find the structure of a field | |
63 | * @param strPoolName the name of the pool | |
64 | * @param strTableName the name of the table | |
65 | * @param strFieldName the name of the field | |
66 | * @param plugin Plugin object | |
67 | * @return the structure of a field | |
68 | */ | |
69 | public static Field findByPrimaryKey( String strPoolName, String strTableName, String strFieldName, Plugin plugin ) | |
70 | { | |
71 | 0 | return _dao.load( strPoolName, strTableName, strFieldName, plugin ); |
72 | } | |
73 | ||
74 | /** | |
75 | * Find the type label of the field in adminsql database | |
76 | * @return the type label of the field in adminsql database | |
77 | * @param strPoolName the name of the pool | |
78 | * @param plugin Plugin adminsq | |
79 | */ | |
80 | public static ReferenceList findFieldType( String strPoolName, Plugin plugin ) | |
81 | { | |
82 | 0 | return _dao.selectFieldTypeList( strPoolName, plugin ); |
83 | } | |
84 | ||
85 | /** | |
86 | * Find the key of the field in adminsql database if exists | |
87 | * @param strPoolName the name of the pool | |
88 | * @param plugin Plugin adminsq | |
89 | * @return the key of the field in adminsql database if exists | |
90 | */ | |
91 | public static ReferenceList findFieldKey( String strPoolName, Plugin plugin ) | |
92 | { | |
93 | 0 | return _dao.selectFieldKeyList( strPoolName, plugin ); |
94 | } | |
95 | ||
96 | /** | |
97 | * Find the null value of the field in adminsql database if exists | |
98 | * @param strPoolName the name of the pool | |
99 | * @param plugin Plugin adminsq | |
100 | * @return the null value of the field in adminsql database if exists | |
101 | */ | |
102 | public static ReferenceList findFieldNull( String strPoolName, Plugin plugin ) | |
103 | { | |
104 | 0 | return _dao.selectFieldNullList( strPoolName, plugin ); |
105 | } | |
106 | ||
107 | /** | |
108 | * Create an intance of a field | |
109 | * @param strPoolName the name of the pool | |
110 | * @param strTableName the name of the table | |
111 | * @param field Field object | |
112 | * @param plugin Plugin adminsql | |
113 | * @return list of fields | |
114 | */ | |
115 | public static Field create( String strPoolName, String strTableName, Field field, Plugin plugin ) | |
116 | { | |
117 | 0 | _dao.insert( strPoolName, strTableName, field, plugin ); |
118 | ||
119 | 0 | return field; |
120 | } | |
121 | ||
122 | /** | |
123 | * Delete a field in a table | |
124 | * @param strTableName the name of the table | |
125 | * @param strFieldName the name of the field | |
126 | * @param plugin Plugin adminsql | |
127 | */ | |
128 | public static void remove( String strTableName, String strFieldName, Plugin plugin ) | |
129 | { | |
130 | 0 | _dao.delete( strTableName, strFieldName, plugin ); |
131 | 0 | } |
132 | ||
133 | /** | |
134 | * Update a field structure | |
135 | * @param strPoolName the name of the pool | |
136 | * @param strTableName the name of the table | |
137 | * @param field Field object | |
138 | * @param strFieldNameToModify the name of the field before modification for the request | |
139 | * @param nIdOldFieldKey keep the key of the field | |
140 | * @param plugin Plugin adminsql | |
141 | * @return list of fields | |
142 | */ | |
143 | public static Field update( String strPoolName, String strTableName, Field field, String strFieldNameToModify, | |
144 | int nIdOldFieldKey, Plugin plugin ) | |
145 | { | |
146 | 0 | _dao.store( strPoolName, strTableName, field, strFieldNameToModify, nIdOldFieldKey, plugin ); |
147 | ||
148 | 0 | return field; |
149 | } | |
150 | } |