本文整理了Java中org.openmrs.Obs.setGroupMembers()
方法的一些代码示例,展示了Obs.setGroupMembers()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Obs.setGroupMembers()
方法的具体详情如下:
包路径:org.openmrs.Obs
类名称:Obs
方法名:setGroupMembers
[英]Set the members of the obs group, if this obs is a group.
If it's not a group (i.e. #getConcept(). org.openmrs.Concept#getSet() is not true, then this returns null.
[中]如果obs是一个组,则设置obs组的成员。
如果它不是一个组(即#getConcept()。组织。openmrs。概念#getSet()为非真,则返回null。
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setGroupMembers(Set)
*/
@Test
public void setGroupMembers_shouldNotMarkTheObsAsDirtyWhenTheSetIsReplacedWithAnotherWithSameMembers() throws Exception {
Obs obs = new Obs();
Obs o = new Obs();
Set<Obs> members1 = new HashSet<>();
members1.add(o);
obs.setGroupMembers(members1);
resetObs(obs);
Set<Obs> members2 = new HashSet<>();
members2.add(o);
obs.setGroupMembers(members2);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setGroupMembers(Set)
*/
@Test
public void setGroupMembers_shouldNotMarkTheObsAsDirtyWhenTheSetIsChangedFromNullToAnEmptyOne() throws Exception {
Obs obs = new Obs();
assertNull(Obs.class.getDeclaredField("groupMembers").get(obs));
obs.setGroupMembers(new HashSet<>());
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setGroupMembers(Set)
*/
@Test
public void setGroupMembers_shouldNotMarkNewObsAsDirtyWhenTheSetIsChangedFromNullToANonEmptyOne() throws Exception {
Obs obs = new Obs();
assertNull(Obs.class.getDeclaredField("groupMembers").get(obs));
Set<Obs> members = new HashSet<>();
members.add(new Obs());
obs.setGroupMembers(members);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setGroupMembers(Set)
*/
@Test
public void setGroupMembers_shouldNotMarkTheExistingObsAsDirtyWhenTheSetIsChangedFromNullToANonEmptyOne() throws Exception {
Obs obs = new Obs(5);
assertNull(Obs.class.getDeclaredField("groupMembers").get(obs));
Set<Obs> members = new HashSet<>();
members.add(new Obs());
obs.setGroupMembers(members);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setGroupMembers(Set)
*/
@Test
public void setGroupMembers_shouldNotMarkTheExistingObsAsDirtyWhenTheSetIsReplacedWithAnotherWithDifferentMembers()
throws Exception {
Obs obs = new Obs(2);
Set<Obs> members1 = new HashSet<>();
members1.add(new Obs());
obs.setGroupMembers(members1);
resetObs(obs);
Set<Obs> members2 = new HashSet<>();
members2.add(new Obs());
obs.setGroupMembers(members2);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#setGroupMembers(Set)
*/
@Test
public void setGroupMembers_shouldNotMarkTheNewObsAsDirtyWhenTheSetIsReplacedWithAnotherWithDifferentMembers()
throws Exception {
Obs obs = new Obs();
Set<Obs> members1 = new HashSet<>();
members1.add(new Obs());
obs.setGroupMembers(members1);
assertFalse(obs.isDirty());
Set<Obs> members2 = new HashSet<>();
members2.add(new Obs());
obs.setGroupMembers(members2);
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#getGroupMembers(boolean)
*/
@Test
public void getGroupMembers_shouldGetAllGroupMembersIfPassedTrueAndNonvoidedIfPassedFalse() throws Exception {
Obs parent = new Obs(1);
Set<Obs> members = new HashSet<>();
members.add(new Obs(101));
members.add(new Obs(103));
Obs voided = new Obs(99);
voided.setVoided(true);
members.add(voided);
parent.setGroupMembers(members);
members = parent.getGroupMembers(true);
assertEquals("set of all members should have length of 3", 3, members.size());
members = parent.getGroupMembers(false);
assertEquals("set of non-voided should have length of 2", 2, members.size());
members = parent.getGroupMembers(); // should be same as false
assertEquals("default should return non-voided with length of 2", 2, members.size());
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see ObsValidator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
@Test
public void validate_shouldFailValidationIfObsAncestorsContainsObs() {
Obs obs = new Obs();
obs.setPerson(Context.getPersonService().getPerson(2));
obs.setConcept(Context.getConceptService().getConcept(3)); // datatype = N/A
obs.setObsDatetime(new Date());
Set<Obs> group = new HashSet<>();
group.add(obs);
obs.setGroupMembers(group);
Errors errors = new BindException(obs, "obs");
obsValidator.validate(obs, errors);
assertFalse(errors.hasFieldErrors("person"));
assertFalse(errors.hasFieldErrors("concept"));
assertFalse(errors.hasFieldErrors("obsDatetime"));
assertTrue(errors.hasFieldErrors("groupMembers"));
}
代码示例来源:origin: openmrs/openmrs-core
/**
* @see Obs#isDirty()
*/
@Test
public void isDirty_shouldReturnFalseWhenNoChangeHasBeenMade() throws Exception {
assertFalse(new Obs().isDirty());
//Should also work if setters are called with same values as the original
Obs obs = createObs(2);
obs.setGroupMembers(new LinkedHashSet<>());
obs.getConcept().setDatatype(new ConceptDatatype());
assertFalse(obs.isDirty());
BeanUtils.copyProperties(obs, BeanUtils.cloneBean(obs));
assertFalse(obs.isDirty());
obs = createObs(null);
obs.setGroupMembers(new LinkedHashSet<>());
obs.getConcept().setDatatype(new ConceptDatatype());
assertFalse(obs.isDirty());
BeanUtils.copyProperties(obs, BeanUtils.cloneBean(obs));
assertFalse(obs.isDirty());
}
代码示例来源:origin: openmrs/openmrs-module-webservices.rest
/**
* Sets the members of an obs group
*
* @param obsGroup the obs group whose members to set
* @param members the members to set
*/
@PropertySetter("groupMembers")
public static void setGroupMembers(Obs obsGroup, Set<Obs> members) {
for (Obs member : members) {
member.setObsGroup(obsGroup);
}
obsGroup.setGroupMembers(members);
}
代码示例来源:origin: openmrs/openmrs-core
group.add(Context.getObsService().getObs(7));
group.add(Context.getObsService().getObs(9));
obs.setGroupMembers(group);
代码示例来源:origin: openmrs/openmrs-module-htmlformentry
/**
* Returns a copy of an Obs. Recurses through GroupMembers to return copies of those also, so
* the whole Obs tree is a copy.
*
* @param obsToCopy
* @param replacements
* @return
* @throws Exception
*/
private static Obs returnObsCopy(Obs obsToCopy, Map<Obs, Obs> replacements) throws Exception {
Obs newObs = (Obs) returnCopy(obsToCopy);
if (obsToCopy.isObsGrouping()) {
newObs.setGroupMembers(null);
for (Obs oinner : obsToCopy.getGroupMembers()) {
Obs oinnerNew = returnObsCopy(oinner, replacements);
newObs.addGroupMember(oinnerNew);
}
}
replacements.put(newObs, obsToCopy);
return newObs;
}
内容来源于网络,如有侵权,请联系作者删除!