Browse Source

add roles to label

Shinsuke Sugaya 9 years ago
parent
commit
c1120d5745

+ 13 - 1
src/main/java/org/codelibs/fess/app/service/LabelTypeService.java

@@ -191,7 +191,19 @@ public class LabelTypeService implements Serializable {
     }
 
     public OptionalEntity<LabelType> getLabelType(final String id) {
-        return labelTypeBhv.selectByPK(id);
+        return labelTypeBhv.selectByPK(id).map(entity -> {
+            final List<LabelToRole> wctrtmList = labelToRoleBhv.selectList(wctrtmCb -> {
+                wctrtmCb.query().setLabelTypeId_Equal(entity.getId());
+            });
+            if (!wctrtmList.isEmpty()) {
+                final List<String> roleTypeIds = new ArrayList<String>(wctrtmList.size());
+                for (final LabelToRole mapping : wctrtmList) {
+                    roleTypeIds.add(mapping.getRoleTypeId());
+                }
+                entity.setRoleTypeIds(roleTypeIds.toArray(new String[roleTypeIds.size()]));
+            }
+            return entity;
+        });
     }
 
 }

+ 0 - 1
src/main/java/org/codelibs/fess/app/web/admin/labeltype/AdminLabeltypeAction.java

@@ -16,7 +16,6 @@
 
 package org.codelibs.fess.app.web.admin.labeltype;
 
-
 import javax.annotation.Resource;
 
 import org.codelibs.fess.Constants;