/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package beans.cec;
import framework.beans.SecuredBean;
import framework.beans.security.BeanRights;
import beans.cec.entity.CommitteeDirection;
import beans.cec.entity.CommitteeDirectionDetails;
import beans.cec.entity.CommitteeResolution;
import beans.cec.entity.CommitteeResolutionDetails;
import beans.cec.entity.Inability;
import beans.cec.entity.InabilityDetails;
import framework.generic.ClipsServerException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.ejb.Stateful;
import beans.UserRightsSet; import framework.security.RightChecker;
/**
* @security ok
* @author lacoste
*/
@Stateful(mappedName="clips-beans/InabilityFactoryBean")
public class InabilityFactoryBean extends SecuredBean implements InabilityFactoryBeanRemote {
public static int COMMAND_READ = 0;
@Override
protected void initBeanRights() {
int [] r = new int[1];
r[COMMAND_READ] = RightPresence(UserRightsSet.READ_MEDICAL_DATA.id);
rights = new BeanRights(r);
}
/**
* Возвращает информацию о направлениях на МСЭК, для указанного клиента
* @param clientID идентификатор клиента
* @return список направлений на МСЭК
* @throws generic.ClipsServerException
* @security READ_MEDICAL_DATA
*/
@Override
public List<InabilityDetails> getClientInabilityDatas(int clientID) throws ClipsServerException {
checkCommandAccessibility(COMMAND_READ);
List<InabilityDetails> res = new ArrayList<InabilityDetails>();
Field fields[] = {
new Field("committeeResolution.direction.direction.serviceRender.disease.emc.client.id", clientID)
};
List inabilityList = findEntityList(Inability.class, fields);
Iterator i = inabilityList.iterator();
while (i.hasNext()) {
Inability j = (Inability) i.next();
res.add(j.getDetails((RightChecker) this));
}
return res;
}
/**
* Возвращает информацию о решениях КЭК, для указанного клиента
* @param clientID идентификатор клиента
* @return список направлений на МСЭК
* @throws generic.ClipsServerException
* @security READ_MEDICAL_DATA
*/
@Override
public List<CommitteeResolutionDetails> getClientComResDatas(int clientID) throws ClipsServerException {
checkCommandAccessibility(COMMAND_READ);
List<CommitteeResolutionDetails> res = new ArrayList<CommitteeResolutionDetails>();
Field fields[] = {new Field("direction.direction." +
"serviceRender.disease.emc.client.id", clientID)};
List inabilityList = findEntityList(CommitteeResolution.class, fields);
Iterator i = inabilityList.iterator();
while (i.hasNext()) {
CommitteeResolution j = (CommitteeResolution) i.next();
res.add(j.getDetails((RightChecker) this));
}
return res;
}
/**
* Возвращает информацию о направлениях на КЭК, для указанного клиента
* @param clientID идентификатор клиента
* @return список направлений на МСЭК
* @throws generic.ClipsServerException
* @security READ_MEDICAL_DATA
*/
@Override
public List<CommitteeDirectionDetails> getClientComDirDatas(int clientID) throws ClipsServerException {
checkCommandAccessibility(COMMAND_READ);
List<CommitteeDirectionDetails> detComDir = new ArrayList<CommitteeDirectionDetails>();
Field fields[] = {new Field("direction." +
"serviceRender.disease.emc.client.id", clientID)};
List inabilityList = findEntityList(CommitteeDirection.class, fields);
Iterator i = inabilityList.iterator();
while (i.hasNext()) {
CommitteeDirection j = (CommitteeDirection) i.next();
detComDir.add(j.getDetails((RightChecker) this));
}
return detComDir;
}
}