import ims.framework.interfaces.IAppUser; //导入方法依赖的package包/类
public ILocation[] listConfiguredUserLocations(IAppUser user)
{
if (user == null)
throw new RuntimeException("Invalid user");
if (user.getMosId() == null)
return new ILocation[0];
DomainFactory factory = getDomainFactory();
// Get the member of staff and the location from database
MemberOfStaffVo memberOfStaff = MemberOfStaffVoAssembler.create((MemberOfStaff) factory.getDomainObject(MemberOfStaff.class, user.getMosId()));
// If the member of staff has no locations - return false
if (memberOfStaff.getLocations() == null)
return new ILocation[0];
LocationLiteVoCollection locColl = new LocationLiteVoCollection();
// Check for a location for the member of staff
for (int i = 0; i < memberOfStaff.getLocations().size(); i++)
{
HcpLocationVo hcpLocation = memberOfStaff.getLocations().get(i);
// Skip to next location if the HCP location is null or HCP location doesn't have a location
if (hcpLocation == null)
continue;
if (hcpLocation.getLocation() == null)
continue;
if (hcpLocation.getLocation().getIsActiveIsNotNull() && !hcpLocation.getLocation().getIsActive())
continue;
if(hcpLocation.getLocation().getIsVirtualIsNotNull() && hcpLocation.getLocation().getIsVirtual())
continue;
// The locations match - return true
locColl.add(hcpLocation.getLocation());
}
return locColl.size() == 0 ? new ILocation[0] : locColl.sort(true).toILocationArray();
}