put nameDecorated in OfficeLookup view

This commit is contained in:
John Woodlock
2012-07-13 18:25:39 +10:00
parent 1a29bbe97e
commit e26e4aca35
3 changed files with 18 additions and 8 deletions
@@ -18,9 +18,9 @@ public class AppUserData {
private String firstname; private String firstname;
private String lastname; private String lastname;
private String email; private String email;
private List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>(); private List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>();
private List<RoleData> availableRoles = new ArrayList<RoleData>(); private List<RoleData> availableRoles = new ArrayList<RoleData>();
private List<RoleData> selectedRoles = new ArrayList<RoleData>(); private List<RoleData> selectedRoles = new ArrayList<RoleData>();
@@ -6,14 +6,17 @@ public class OfficeLookup implements Serializable {
private Long id; private Long id;
private String name; private String name;
private String nameDecorated;
public OfficeLookup() { public OfficeLookup() {
// //
} }
public OfficeLookup(final Long id, final String name) { public OfficeLookup(final Long id, final String name,
final String nameDecorated) {
this.id = id; this.id = id;
this.name = name; this.name = name;
this.nameDecorated = nameDecorated;
} }
public Long getId() { public Long getId() {
@@ -24,4 +27,8 @@ public class OfficeLookup implements Serializable {
return this.name; return this.name;
} }
public String getNameDecorated() {
return nameDecorated;
}
} }
@@ -26,6 +26,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
private final SimpleJdbcTemplate jdbcTemplate; private final SimpleJdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context; private final PlatformSecurityContext context;
private final static String nameDecoratedBaseOnHierarchy = "concat(substring('........................................', 1, ((LENGTH(o.hierarchy) - LENGTH(REPLACE(o.hierarchy, '.', '')) - 1) * 4)), o.name)";
@Autowired @Autowired
public OfficeReadPlatformServiceImpl(final PlatformSecurityContext context, public OfficeReadPlatformServiceImpl(final PlatformSecurityContext context,
@@ -38,7 +39,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
public String officeSchema() { public String officeSchema() {
return " o.id as id, o.name as name, " return " o.id as id, o.name as name, "
+ "concat(substring('........................................', 1, ((LENGTH(o.hierarchy) - LENGTH(REPLACE(o.hierarchy, '.', '')) - 1) * 4)), o.name)" + nameDecoratedBaseOnHierarchy
+ " as nameDecorated, o.external_id as externalId, o.opening_date as openingDate, o.hierarchy as hierarchy, parent.id as parentId, parent.name as parentName " + " as nameDecorated, o.external_id as externalId, o.opening_date as openingDate, o.hierarchy as hierarchy, parent.id as parentId, parent.name as parentName "
+ "from org_office o LEFT JOIN org_office AS parent ON parent.id = o.parent_id "; + "from org_office o LEFT JOIN org_office AS parent ON parent.id = o.parent_id ";
} }
@@ -56,8 +57,8 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
Long parentId = JdbcSupport.getLong(rs, "parentId"); Long parentId = JdbcSupport.getLong(rs, "parentId");
String parentName = rs.getString("parentName"); String parentName = rs.getString("parentName");
return new OfficeData(id, name, nameDecorated, externalId, openingDate, hierarchy, return new OfficeData(id, name, nameDecorated, externalId,
parentId, parentName); openingDate, hierarchy, parentId, parentName);
} }
} }
@@ -65,7 +66,8 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
RowMapper<OfficeLookup> { RowMapper<OfficeLookup> {
public String officeLookupSchema() { public String officeLookupSchema() {
return " o.id as id, o.name as name from org_office o "; return " o.id as id, " + nameDecoratedBaseOnHierarchy
+ " as nameDecorated, o.name as name from org_office o ";
} }
@Override @Override
@@ -74,8 +76,9 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
Long id = rs.getLong("id"); Long id = rs.getLong("id");
String name = rs.getString("name"); String name = rs.getString("name");
String nameDecorated = rs.getString("nameDecorated");
return new OfficeLookup(id, name); return new OfficeLookup(id, name, nameDecorated);
} }
} }