All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.venky.swf.plugins.collab.extensions.participation.CompanySpecificParticipantExtension Maven / Gradle / Ivy

There is a newer version: 2.12
Show newest version
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;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy