1 /*
2 * Copyright 2012-2021 CodeLibs Project and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.codelibs.fess.es.user.bsentity;
17
18 import java.time.LocalDateTime;
19 import java.util.HashMap;
20 import java.util.Map;
21
22 import org.codelibs.fess.es.user.allcommon.EsAbstractEntity;
23 import org.codelibs.fess.es.user.bsentity.dbmeta.RoleDbm;
24
25 /**
26 * ${table.comment}
27 * @author ESFlute (using FreeGen)
28 */
29 public class BsRole extends EsAbstractEntity {
30
31 // ===================================================================================
32 // Definition
33 // ==========
34 private static final long serialVersionUID = 1L;
35 protected static final Class<?> suppressUnusedImportLocalDateTime = LocalDateTime.class;
36
37 // ===================================================================================
38 // Attribute
39 // =========
40 /** name */
41 protected String name;
42
43 // [Referrers] *comment only
44
45 // ===================================================================================
46 // DB Meta
47 // =======
48 @Override
49 public RoleDbm asDBMeta() {
50 return RoleDbm.getInstance();
51 }
52
53 @Override
54 public String asTableDbName() {
55 return "role";
56 }
57
58 // ===================================================================================
59 // Source
60 // ======
61 @Override
62 public Map<String, Object> toSource() {
63 Map<String, Object> sourceMap = new HashMap<>();
64 if (name != null) {
65 addFieldToSource(sourceMap, "name", name);
66 }
67 return sourceMap;
68 }
69
70 protected void addFieldToSource(Map<String, Object> sourceMap, String field, Object value) {
71 sourceMap.put(field, value);
72 }
73
74 // ===================================================================================
75 // Basic Override
76 // ==============
77 @Override
78 protected String doBuildColumnString(String dm) {
79 StringBuilder sb = new StringBuilder();
80 sb.append(dm).append(name);
81 if (sb.length() > dm.length()) {
82 sb.delete(0, dm.length());
83 }
84 sb.insert(0, "{").append("}");
85 return sb.toString();
86 }
87
88 // ===================================================================================
89 // Accessor
90 // ========
91 public String getName() {
92 checkSpecifiedProperty("name");
93 return convertEmptyToNull(name);
94 }
95
96 public void setName(String value) {
97 registerModifiedProperty("name");
98 this.name = value;
99 }
100 }