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.db.model.User;
import com.venky.swf.plugins.collab.db.model.CompanySpecific;
import com.venky.swf.plugins.collab.db.model.participants.admin.Company;
import com.venky.swf.pm.DataSecurityFilter;

public class CompanySpecificParticipantExtension extends ParticipantExtension{

	@Override
	protected List getAllowedFieldValues(User user,
			M partiallyFilledModel, String fieldName) {
		CompanySpecific cs = null;
		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 {
					SequenceSet ids =  DataSecurityFilter.getIds(DataSecurityFilter.getRecordsAccessible(Company.class,user));
					if (!getReflector().isFieldMandatory(fieldName)){
						ids.add(null);
					}
					return ids;
				}
			}else if ("COMPANY_CREATOR_USER_ID".equalsIgnoreCase(fieldName)){
				return Arrays.asList(user.getId());
			}
		}
		return null;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy