package com.validation.manager.core.server.core;

import com.validation.manager.core.DataBaseManager;
import com.validation.manager.core.db.Role;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author Javier A. Ortiz Bultron <javier.ortiz.78@gmail.com>
 */
public class RoleServer extends Role {

    private static final Map<String, Object> PARAMETERS = new HashMap<>();

    public static Role getRole(String role) {
        Role r = null;
        PARAMETERS.clear();
        PARAMETERS.put("name", role);
        List<Object> result = DataBaseManager.namedQuery("Role.findByName",
                PARAMETERS);
        if (!result.isEmpty()) {
            r = (Role) result.get(0);
        }
        return r;
    }
}

@@ -137,15 +137,134 @@
 ore.
-db.Role
+EntityServer;%0D%0Aimport com.validation.manager.core.db.Role;%0D%0Aimport com.validation.manager.core.db.controller.RoleJpaController
 ;%0D%0Ai
@@ -423,16 +423,22 @@
 %0Apublic 
+final 
 class Ro
@@ -458,16 +458,46 @@
 nds Role
+ implements EntityServer%3CRole%3E
  %7B%0D%0A%0D%0A  
@@ -569,16 +569,275 @@
 ap%3C%3E();%0D
+%0A    private final RoleJpaController c%0D%0A            = new RoleJpaController(DataBaseManager.getEntityManagerFactory());%0D%0A%0D%0A    public RoleServer(String description) %7B%0D%0A        super(description);%0D%0A        update(RoleServer.this, getRole(description));%0D%0A    %7D%0D
 %0A%0D%0A    p
@@ -1161,16 +1161,16 @@
      %7D%0D%0A
-
         
@@ -1186,12 +1186,1037 @@
 %0D%0A    %7D%0D
+%0A%0D%0A    @Override%0D%0A    public int write2DB() throws Exception %7B%0D%0A        if (getId() == null) %7B%0D%0A            Role r = new Role();%0D%0A            update(r, this);%0D%0A            c.create(r);%0D%0A            update(this, r);%0D%0A        %7D else %7B%0D%0A            Role r = getEntity();%0D%0A            update(r, this);%0D%0A            c.edit(r);%0D%0A            update(this, r);%0D%0A        %7D%0D%0A        return getId();%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public void update() %7B%0D%0A        update(RoleServer.this, getEntity());%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public Role getEntity() %7B%0D%0A        return getId() == null ? null : c.findRole(getId());%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public void update(Role target, Role source) %7B%0D%0A        target.setDescription(source.getDescription());%0D%0A        target.setId(source.getId());%0D%0A        target.setRoleName(source.getRoleName());%0D%0A        target.setUserRightList(source.getUserRightList());%0D%0A        target.setUserTestPlanRoleList(source.getUserTestPlanRoleList());%0D%0A        target.setVmUserList(source.getVmUserList());%0D%0A    %7D%0D
 %0A%7D%0D%0A

Implement EntityServer.