Tabnine Logo
AdministrationService.executeSQL
Code IndexAdd Tabnine to your IDE (free)

How to use
executeSQL
method
in
org.openmrs.api.AdministrationService

Best Java code snippets using org.openmrs.api.AdministrationService.executeSQL (Showing top 11 results out of 315)

origin: openmrs/openmrs-core

  private List<ConceptClass> getConceptClassesOfOrderTypes() {
    List<ConceptClass> mappedClasses = new ArrayList<>();
    AdministrationService administrationService = Context.getAdministrationService();
    List<List<Object>> result = administrationService.executeSQL(
      "SELECT DISTINCT concept_class_id FROM order_type_class_map", true);
    for (List<Object> temp : result) {
      for (Object value : temp) {
        if (value != null) {
          mappedClasses.add(this.getConceptClass((Integer) value));
        }
      }
    }
    return mappedClasses;
  }
}
origin: openmrs/openmrs-core

@Test
public void executeSQL_shouldExecuteSqlContainingGroupBy() {
  
  String sql = "select encounter1_.location_id, encounter1_.creator, encounter1_.encounter_type, encounter1_.form_id, location2_.location_id, count(obs0_.obs_id) from obs obs0_ right outer join encounter encounter1_ on obs0_.encounter_id=encounter1_.encounter_id inner join location location2_ on encounter1_.location_id=location2_.location_id inner join users user3_ on encounter1_.creator=user3_.user_id inner join person user3_1_ on user3_.user_id=user3_1_.person_id inner join encounter_type encountert4_ on encounter1_.encounter_type=encountert4_.encounter_type_id inner join form form5_ on encounter1_.form_id=form5_.form_id where encounter1_.date_created>='2007-05-05' and encounter1_.date_created<= '2008-05-05' group by encounter1_.location_id, encounter1_.creator , encounter1_.encounter_type , encounter1_.form_id";
  adminService.executeSQL(sql, true);
  
  String sql2 = "select encounter_id, count(*) from encounter encounter_id group by encounter_id";
  adminService.executeSQL(sql2, true);
}

origin: openmrs/openmrs-core

@Test
public void executeSQL_shouldReturnNullGivenNull() {
  
  adminService.executeSQL(null, true);
  
  verify(adminDAO, never()).executeSQL(anyString(), anyBoolean());
}

origin: openmrs/openmrs-core

@Test
public void executeSQL_shouldReturnNullGivenEmptyString() {
  
  adminService.executeSQL(" ", true);
  
  verify(adminDAO, never()).executeSQL(anyString(), anyBoolean());
}

origin: openmrs/openmrs-core

for (String sqlStatement : sqlStatements) {
  if (sqlStatement.trim().length() > 0) {
    as.executeSQL(sqlStatement, false);
origin: openmrs/openmrs-core

@Test
public void stopVisits_shouldCloseAllUnvoidedActiveVisitMatchingTheSpecifiedVisitTypes() {
  executeDataSet("org/openmrs/api/include/VisitServiceTest-includeVisitsAndTypeToAutoClose.xml");
  String[] visitTypeNames = StringUtils.split(Context.getAdministrationService().getGlobalProperty(
    OpenmrsConstants.GP_VISIT_TYPES_TO_AUTO_CLOSE), ",");
  
  String openVisitsQuery = "SELECT visit_id FROM visit WHERE voided = 0 AND date_stopped IS NULL AND visit_type_id IN (SELECT visit_type_id FROM visit_type WHERE NAME IN ('"
      + StringUtils.join(visitTypeNames, "','") + "'))";
  int activeVisitCount = Context.getAdministrationService().executeSQL(openVisitsQuery, true).size();
  //sanity check
  assertTrue("There should be some active visits for this test to be valid", activeVisitCount > 0);
  
  //close any unvoided open visits
  visitService.stopVisits(null);
  
  activeVisitCount = Context.getAdministrationService().executeSQL(openVisitsQuery, true).size();
  
  //all active unvoided visits should have been closed
  assertTrue("Not all active unvoided vists were closed", activeVisitCount == 0);
}

origin: openmrs/openmrs-core

/**
 * @see EncounterService#unvoidEncounter(Encounter)
 */
@Test
public void saveEncounter_shouldNotCascadeToExistingOrder() {
  EncounterService es = Context.getEncounterService();
  
  TestOrder order = (TestOrder) Context.getOrderService().getOrder(7);
  order.setVoided(true);
  
  Encounter encounter = es.getEncounter(6);
  es.saveEncounter(encounter);
  
  String sql = "SELECT voided FROM orders WHERE order_id=7";
  Boolean voided = (Boolean) Context.getAdministrationService().executeSQL(sql, true).get(0).get(0);
  Assert.assertFalse(voided);
}

origin: openmrs/openmrs-module-webservices.rest

private int getEncounterProviderCountWithoutFlushingByUuid(String uuid) {
  List<List<Object>> temp = Context.getAdministrationService().executeSQL(
    "select count(*) from encounter_provider where uuid ='" + uuid + "'", true);
  return ((Number) temp.get(0).get(0)).intValue();
}

origin: openmrs/openmrs-module-webservices.rest

private int getEncounterProviderCountWithoutFlushing() {
  List<List<Object>> temp = Context.getAdministrationService().executeSQL(
    "select count(*) from encounter_provider where encounter_id = 3", true);
  return ((Number) temp.get(0).get(0)).intValue();
}

origin: openmrs/openmrs-module-webservices.rest

  private int getNonVoidedEncounterProviderCount() {
    List<List<Object>> temp = Context.getAdministrationService().executeSQL(
      "select count(*) from encounter_provider where encounter_id = 3 and voided = 0", true);
    return ((Number) temp.get(0).get(0)).intValue();
  }
}
origin: openmrs/openmrs-module-webservices.rest

  @Test
  public void shouldPurgeAConceptName() throws Exception {
    String conceptId = "5497";
    //using sql to be able to include voided names too
    Long before = (Long) Context.getAdministrationService()
        .executeSQL("select count(*) from concept_name where concept_id = " + conceptId, true).get(0).get(0);
    
    handle(newDeleteRequest("concept/" + conceptUuid2 + "/name/8230adbf-30a9-4e18-b6d7-fc57e0c23cab", new Parameter(
        "purge", "")));
    
    Long after = (Long) Context.getAdministrationService()
        .executeSQL("select count(*) from concept_name where concept_id = " + conceptId, true).get(0).get(0);
    Assert.assertEquals(before.longValue() - 1, after.longValue());
  }
}
org.openmrs.apiAdministrationServiceexecuteSQL

Javadoc

Runs the sql on the database. If selectOnly is flagged then any non-select sql statements will be rejected.

Popular methods of AdministrationService

  • saveGlobalProperty
    Save the given global property to the database
  • getGlobalProperty
    Gets the global property that has the given propertyName If propertyName is not found in the list of
  • getGlobalPropertyObject
    Gets the global property that has the given propertyName
  • getAllGlobalProperties
    Get a list of all global properties in the system
  • getAllowedLocales
    Gets the list of locales which the administrator has allowed for use on the system. This is specifie
  • getGlobalPropertiesByPrefix
    Gets all global properties that begin with prefix.
  • getGlobalPropertyByUuid
    Get a global property by its uuid. There should be only one of these in the database (well, in the w
  • getGlobalPropertyValue
    Returns a global property according to the type specified
  • purgeGlobalProperty
    Completely remove the given global property from the database
  • addGlobalPropertyListener
    Allows code to be notified when a global property is created/edited/deleted.
  • getSearchLocales
    Returns a list of locales used by the user when searching.
  • getSystemVariables
    Get a listing or important variables used in openmrs
  • getSearchLocales,
  • getSystemVariables,
  • setGlobalProperty,
  • setImplementationId,
  • validate,
  • getGlobalPropertiesBySuffix,
  • getImplementationId,
  • getMaximumPropertyLength,
  • getPresentationLocales

Popular in Java

  • Start an intent from android
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • onCreateOptionsMenu (Activity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now