com.venky.swf.plugins.collab.extensions.participation.CompanySpecificParticipantExtension Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of swf-plugin-collab Show documentation
Show all versions of swf-plugin-collab Show documentation
Succinct Web Framework - Plugin collaboration
package com.venky.swf.plugins.collab.extensions.participation;
import java.util.Arrays;
import java.util.List;
import com.venky.core.collections.SequenceSet;
import com.venky.swf.db.extensions.ParticipantExtension;
import com.venky.swf.db.model.Model;
import com.venky.swf.plugins.collab.db.model.CompanySpecific;
import com.venky.swf.plugins.collab.db.model.user.User;
import com.venky.swf.plugins.collab.db.model.user.UserCompany;
public class CompanySpecificParticipantExtension extends ParticipantExtension{
@Override
protected List getAllowedFieldValues(com.venky.swf.db.model.User user, M partiallyFilledModel, String fieldName) {
CompanySpecific cs = null;
User u = (User)user;
if (CompanySpecific.class.isInstance(partiallyFilledModel)){
cs = (CompanySpecific)partiallyFilledModel;
}
if (cs != null){
if ("COMPANY_ID".equalsIgnoreCase(fieldName)){
if (cs.getCompanyId() != null && cs.getCompany().isAccessibleBy(user)){
return Arrays.asList(cs.getCompanyId());
}else {
List ucs = u.getUserCompanies();
SequenceSet ids = new SequenceSet<>();
for (UserCompany uc:ucs){
ids.add(uc.getCompanyId());
}
return ids;
}
}
}
return null;
}
}