Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 14ee1bff6932
Choose a base ref
...
head repository: openmrs/openmrs-core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 68ca307767d7
Choose a head ref
  • 2 commits
  • 4 files changed
  • 2 contributors

Commits on Mar 1, 2013

  1. Copy the full SHA
    ec95851 View commit details

Commits on Apr 30, 2013

  1. Merge pull request #236 from wluyima/TRUNK-3690

    Foreign key constraint violation on ConceptWord when removing a concept name - TRUNK-3690
    dkayiwa committed Apr 30, 2013
    Copy the full SHA
    68ca307 View commit details
1 change: 1 addition & 0 deletions api/src/main/java/org/openmrs/api/ConceptService.java
Original file line number Diff line number Diff line change
@@ -186,6 +186,7 @@ public interface ConceptService extends OpenmrsService {
* @should set audit info if an item is removed from any of its child collections
* @should set audit info if any item in the child collections is edited
* @should set audit info if an item is added to any of its child collections
* @should pass when saving a concept after removing a name
*/
@Authorized( { PrivilegeConstants.MANAGE_CONCEPTS })
public Concept saveConcept(Concept concept) throws APIException;
Original file line number Diff line number Diff line change
@@ -287,11 +287,6 @@ else if (!CollectionUtils.isEmpty(concept.getSynonyms(locale)))
concept.setDateChanged(new Date());
concept.setChangedBy(Context.getAuthenticatedUser());

Errors errors = new BindException(concept, "concept");
new ConceptValidator().validate(concept, errors);
if (errors.hasErrors())
throw new APIException("Validation errors found: " + errors.getAllErrors());

Concept conceptToReturn = dao.saveConcept(concept);

// add/remove entries in the concept_word table (used for searching)
15 changes: 9 additions & 6 deletions api/src/test/java/org/openmrs/aop/AuthorizationAdviceTest.java
Original file line number Diff line number Diff line change
@@ -4,9 +4,11 @@
*/
package org.openmrs.aop;

import java.util.ArrayList;
import java.util.List;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.annotation.Resource;

import org.junit.Assert;
import org.junit.Test;
import org.openmrs.Concept;
@@ -52,19 +54,20 @@ public void before_shouldNotifyListenersAboutCheckedPrivileges() {
Context.getConceptService().saveConcept(concept);

Assert.assertArrayEquals("listener 1 save concept: " + listener1.hasPrivileges.toString(), new String[] {
"Manage Concepts", "Get Concepts", "Get Observations", "Get Concepts" }, listener1.hasPrivileges.toArray());
"Manage Concepts", "Get Concepts", "Get Observations" }, listener1.hasPrivileges.toArray());
Assert.assertArrayEquals("listener 2 save concept: " + listener2.hasPrivileges.toString(), new String[] {
"Manage Concepts", "Get Concepts", "Get Observations", "Get Concepts" }, listener2.hasPrivileges.toArray());
"Manage Concepts", "Get Concepts", "Get Observations" }, listener2.hasPrivileges.toArray());
Assert.assertEquals(0, listener1.lacksPrivileges.size());
Assert.assertEquals(0, listener2.lacksPrivileges.size());
}

@Component("listener1")
public static class Listener1 implements PrivilegeListener {

public List<String> hasPrivileges = new ArrayList<String>();
//We need to preserve order due to the semantics of Assert.assertArrayEquals
public Set<String> hasPrivileges = new LinkedHashSet<String>();

public List<String> lacksPrivileges = new ArrayList<String>();
public Set<String> lacksPrivileges = new LinkedHashSet<String>();

@Override
public void privilegeChecked(User user, String privilege, boolean hasPrivilege) {
12 changes: 12 additions & 0 deletions api/src/test/java/org/openmrs/api/ConceptServiceTest.java
Original file line number Diff line number Diff line change
@@ -2620,4 +2620,16 @@ public void mapConceptProposalToConcept_shouldFailWhenAddingADuplicateSyonymn()
cs.mapConceptProposalToConcept(cp, mappedConcept, locale);
}

/**
* @see {@link ConceptService#saveConcept(Concept)}
*/
@Test
@Verifies(value = "should pass when saving a concept after removing a name", method = "saveConcept(Concept)")
public void saveConcept_shouldPassWhenSavingAConceptAfterRemovingAName() throws Exception {
executeDataSet("org/openmrs/api/include/ConceptServiceTest-words.xml");
Concept concept = conceptService.getConcept(3000);
Assert.assertFalse(concept.getSynonyms().isEmpty());
concept.removeName(concept.getSynonyms().iterator().next());
conceptService.saveConcept(concept);
}
}