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 lastname;
private String email;
private List<OfficeLookup> allowedOffices = new ArrayList<OfficeLookup>();
private List<RoleData> availableRoles = new ArrayList<RoleData>();
private List<RoleData> selectedRoles = new ArrayList<RoleData>();
@@ -6,14 +6,17 @@ public class OfficeLookup implements Serializable {
private Long id;
private String name;
private String nameDecorated;
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.name = name;
this.nameDecorated = nameDecorated;
}
public Long getId() {
@@ -24,4 +27,8 @@ public class OfficeLookup implements Serializable {
return this.name;
}
public String getNameDecorated() {
return nameDecorated;
}
}
@@ -26,6 +26,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
private final SimpleJdbcTemplate jdbcTemplate;
private final PlatformSecurityContext context;
private final static String nameDecoratedBaseOnHierarchy = "concat(substring('........................................', 1, ((LENGTH(o.hierarchy) - LENGTH(REPLACE(o.hierarchy, '.', '')) - 1) * 4)), o.name)";
@Autowired
public OfficeReadPlatformServiceImpl(final PlatformSecurityContext context,
@@ -38,7 +39,7 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
public String officeSchema() {
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 "
+ "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");
String parentName = rs.getString("parentName");
return new OfficeData(id, name, nameDecorated, externalId, openingDate, hierarchy,
parentId, parentName);
return new OfficeData(id, name, nameDecorated, externalId,
openingDate, hierarchy, parentId, parentName);
}
}
@@ -65,7 +66,8 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
RowMapper<OfficeLookup> {
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
@@ -74,8 +76,9 @@ public class OfficeReadPlatformServiceImpl implements OfficeReadPlatformService
Long id = rs.getLong("id");
String name = rs.getString("name");
String nameDecorated = rs.getString("nameDecorated");
return new OfficeLookup(id, name);
return new OfficeLookup(id, name, nameDecorated);
}
}