当前位置: 首页>>代码示例>>Java>>正文


Java ServiceFactory.getInstance方法代码示例

本文整理汇总了Java中org.sunbird.helper.ServiceFactory.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceFactory.getInstance方法的具体用法?Java ServiceFactory.getInstance怎么用?Java ServiceFactory.getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.sunbird.helper.ServiceFactory的用法示例。


在下文中一共展示了ServiceFactory.getInstance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCourseBatchDbStatus

import org.sunbird.helper.ServiceFactory; //导入方法依赖的package包/类
/**
*  
* @param value
*/
public static void updateCourseBatchDbStatus(Map<String,Object> map,Boolean increment) {
  ProjectLogger.log("updating course batch details start",LoggerEnum.INFO.name());
  CassandraOperation cassandraOperation = ServiceFactory.getInstance();
  Util.DbInfo courseBatchDBInfo = Util.dbInfoMap.get(JsonKey.COURSE_BATCH_DB);
  try{
    String response = doOperationInEkStepCourse((String)map.get(JsonKey.COURSE_ID),increment,(String)map.get(JsonKey.ENROLLMENT_TYPE));
    if(response.equals(JsonKey.SUCCESS)){
      boolean flag = updateDataIntoES(map);
      if(flag){
        cassandraOperation.updateRecord(courseBatchDBInfo.getKeySpace(), courseBatchDBInfo.getTableName(), map);
      }
    }else{
      ProjectLogger.log("Ekstep content updatation failed.",LoggerEnum.INFO.name());
    }
  }catch(Exception e){
    ProjectLogger.log("Exception occured while savin data to course batch db ", e);
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:23,代码来源:CourseBatchSchedulerUtil.java

示例2: execute

import org.sunbird.helper.ServiceFactory; //导入方法依赖的package包/类
@Override
public void execute(JobExecutionContext ctx) throws JobExecutionException {
  ProjectLogger.log("Running Update user count Scheduler Job at: " + Calendar.getInstance().getTime()
      + " triggered by: " + ctx.getJobDetail().toString(), LoggerEnum.INFO.name());
  List<Object> locIdList = new ArrayList<>();
  Util.DbInfo geoLocationDbInfo = Util.dbInfoMap.get(JsonKey.GEO_LOCATION_DB);
  CassandraOperation cassandraOperation = ServiceFactory.getInstance();
  Response response = cassandraOperation.getAllRecords(geoLocationDbInfo.getKeySpace(), geoLocationDbInfo.getTableName());
  List<Map<String, Object>> list = (List<Map<String, Object>>) response.get(JsonKey.RESPONSE);
  for(Map<String, Object> map : list){
    if(null == map.get(JsonKey.USER_COUNT) || 0 == ((int)map.get(JsonKey.USER_COUNT))){
     locIdList.add(map.get(JsonKey.ID));
    }
  }
  ProjectLogger.log("size of total locId to processed = "+locIdList.size());
  Request request = new Request();
  request.setOperation(ActorOperations.UPDATE_USER_COUNT_TO_LOCATIONID.getValue());
  request.getRequest().put(JsonKey.LOCATION_IDS, locIdList);
  request.getRequest().put(JsonKey.OPERATION, "UpdateUserCountScheduler");
  ProjectLogger.log("calling BackgroundService actor from scheduler");
  ActorUtil.tell(request);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:23,代码来源:UpdateUserCountScheduler.java

示例3: getUserNamebyUserId

import org.sunbird.helper.ServiceFactory; //导入方法依赖的package包/类
/**
 * This method will provide user name based on user id if user not found
 * then it will return null.
 *
 * @param userId String
 * @return String
 */
@SuppressWarnings("unchecked")
public static String getUserNamebyUserId(String userId) {
    CassandraOperation cassandraOperation = ServiceFactory.getInstance();
    Util.DbInfo userdbInfo = Util.dbInfoMap.get(JsonKey.USER_DB);
    Response result = cassandraOperation.getRecordById(userdbInfo.getKeySpace(), userdbInfo.getTableName(), userId);
    List<Map<String, Object>> list = (List<Map<String, Object>>) result.get(JsonKey.RESPONSE);
    if (!(list.isEmpty())) {
        return (String) (list.get(0).get(JsonKey.USERNAME));
    }
    return null;
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:19,代码来源:Util.java

示例4: setUp

import org.sunbird.helper.ServiceFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() {
  CassandraOperation operation = ServiceFactory.getInstance();
    Application.startLocalActorSystem();
    system = ActorSystem.create("system");
    Util.checkCassandraDbConnections(JsonKey.SUNBIRD);
    userManagementDB = Util.dbInfoMap.get(JsonKey.USER_DB);
    addressDB = Util.dbInfoMap.get(JsonKey.ADDRESS_DB);
    orgTypeDbInfo = Util.dbInfoMap.get(JsonKey.ORG_TYPE_DB);
    orgDB = Util.dbInfoMap.get(JsonKey.ORG_DB);
    locationDB = Util.dbInfoMap.get(JsonKey.GEO_LOCATION_DB);
    Map<String , Object> geoLocation = new HashMap<>();
    // need to delete in after class...
    geoLocation.put(JsonKey.ID , LOCATION_ID);
    //geoLocation.put(JsonKey.LOCATION_ID , LOCATION_ID);
    operation.insertRecord(locationDB.getKeySpace(), locationDB.getTableName() ,geoLocation);
    Map<String , Object> parentOrg = new HashMap<>();
    parentOrg.put(JsonKey.ID , parentOrgId);
    operation.upsertRecord(orgDB.getKeySpace() , orgDB.getTableName() , parentOrg);

  Map<String , Object> userMap = new HashMap<>();
  userMap.put(JsonKey.ID , USER_ID);
  //userMap.put(JsonKey.ROOT_ORG_ID, ROOT_ORG_ID);
  operation.insertRecord(userDbInfo.getKeySpace(), userDbInfo.getTableName(), userMap);
  userMap.put(JsonKey.USER_ID, USER_ID);
  ElasticSearchUtil.createData(EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), USER_ID, userMap);

  Map<String , Object> userMap1 = new HashMap<>();
  userMap1.put(JsonKey.ID , USER_ID+"01");
  //userMap.put(JsonKey.ROOT_ORG_ID, ROOT_ORG_ID);
  operation.insertRecord(userDbInfo.getKeySpace(), userDbInfo.getTableName(), userMap1);
  userMap1.put(JsonKey.USER_ID, USER_ID+"01");
  ElasticSearchUtil.createData(EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), USER_ID, userMap1);


}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:37,代码来源:OrganisationManagementActorTest.java

示例5: destroy

import org.sunbird.helper.ServiceFactory; //导入方法依赖的package包/类
@AfterClass
public static void destroy(){
  CassandraOperation operation = ServiceFactory.getInstance();
  Util.DbInfo clientInfoDB = Util.dbInfoMap.get(JsonKey.CLIENT_INFO_DB);
  //Delete client data from cassandra
  operation.deleteRecord(clientInfoDB.getKeySpace(), clientInfoDB.getTableName(), clientId);
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:8,代码来源:ClientManagementActorTest.java

示例6: execute

import org.sunbird.helper.ServiceFactory; //导入方法依赖的package包/类
public void execute(JobExecutionContext ctx) throws JobExecutionException {
  ProjectLogger.log("Running Upload Scheduler Job at: " + Calendar.getInstance().getTime()
      + " triggered by: " + ctx.getJobDetail().toString(), LoggerEnum.INFO.name());
  Util.DbInfo bulkDb = Util.dbInfoMap.get(JsonKey.BULK_OP_DB);
  CassandraOperation cassandraOperation = ServiceFactory.getInstance();
  List<Map<String, Object>> result = null;
  // get List of process with status as New
  Response res = cassandraOperation.getRecordsByProperty(bulkDb.getKeySpace(),
      bulkDb.getTableName(), JsonKey.STATUS, ProjectUtil.BulkProcessStatus.NEW.getValue());
  result = ((List<Map<String, Object>>) res.get(JsonKey.RESPONSE));
  ProjectLogger.log("Total No. of record in Bulk_upload_process table with status as NEW are : :"
      + result.size(), LoggerEnum.INFO.name());
  if (!result.isEmpty()) {
    process(result);
  }
  // get List of Process with status as InProgress
  res = cassandraOperation.getRecordsByProperty(bulkDb.getKeySpace(), bulkDb.getTableName(),
      JsonKey.STATUS, ProjectUtil.BulkProcessStatus.IN_PROGRESS.getValue());
  result = ((List<Map<String, Object>>) res.get(JsonKey.RESPONSE));
  ProjectLogger
      .log("Total No. of record in Bulk_upload_process table with status as IN_PROGRESS are : :"
          + result.size(), LoggerEnum.INFO.name());
  if (null != result) {
    Iterator<Map<String, Object>> itr = result.iterator();
    while (itr.hasNext()) {
      Map<String, Object> map = itr.next();
      try {
        Date startTime = format.parse((String) map.get(JsonKey.PROCESS_START_TIME));
        Date currentTime = format.parse(format.format(new Date()));
        long difference = currentTime.getTime() - startTime.getTime();
        int hourDiff = (int) (difference / (1000 * 3600));
        // if diff is more than 5Hr then only process it.
        if (hourDiff < 5) {
          itr.remove();
        }
      } catch (Exception ex) {
        ProjectLogger.log(ex.getMessage(), ex);
      }
    }
    if (!result.isEmpty()) {
      ProjectLogger
          .log("Total No. of record in Bulk_upload_process table with status as IN_PROGRESS "
              + "with diff bw start time and current time greater than 5Hr are : :"
              + result.size(), LoggerEnum.INFO.name());
      process(result);
    }
  }
}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:49,代码来源:UploadLookUpScheduler.java

示例7: setUp

import org.sunbird.helper.ServiceFactory; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() {
  CassandraOperation operation = ServiceFactory.getInstance();
  Application.startLocalActorSystem();
  system = ActorSystem.create("system");
  Util.checkCassandraDbConnections(JsonKey.SUNBIRD);
  //userManagementDB = Util.dbInfoMap.get(JsonKey.USER_DB);
  Map<String , Object> userMap = new HashMap<>();
  userMap.put(JsonKey.ID , USER_ID);
  userMap.put(JsonKey.USER_ID, USER_ID);
  //userMap.put(JsonKey.ROOT_ORG_ID, ROOT_ORG_ID);
  operation.insertRecord(userDbInfo.getKeySpace(), userDbInfo.getTableName(), userMap);
  userMap.put(JsonKey.USER_ID, USER_ID);
  userMap.put(JsonKey.ORGANISATION_ID , refOrgId);
  ElasticSearchUtil.createData(EsIndex.sunbird.getIndexName(), EsType.user.getTypeName(), USER_ID, userMap);

  Map<String , Object> orgMap = new HashMap<>();
  orgMap.put(JsonKey.ID , refOrgId);
  operation.insertRecord(orgDB.getKeySpace(), orgDB.getTableName(), orgMap);

  Map<String , Object> batchMap = new HashMap<>();
  batchMap.put(JsonKey.ENROLLMENT_TYPE , JsonKey.INVITE_ONLY);
  batchMap.put(JsonKey.ID , batchId);
  List<String> courseCreatedFor = new ArrayList<>();
  courseCreatedFor.add(refOrgId);
  batchMap.put(JsonKey.COURSE_CREATED_FOR ,courseCreatedFor);
  batchMap.put(JsonKey.COURSE_ID,"do_212282810555342848180");
  batchMap.put(JsonKey.STATUS, ProgressStatus.STARTED.getValue());
  operation.insertRecord(batchDbInfo.getKeySpace(), batchDbInfo.getTableName(), batchMap);

  batchMap.put(JsonKey.BATCH_ID , batchId);
  ElasticSearchUtil.createData(EsIndex.sunbird.getIndexName(), EsType.course.getTypeName(), USER_ID, batchMap);

  Map<String , Object> userOrgMap = new HashMap<>();
  userOrgMap.put(JsonKey.USER_ID, USER_ID);
  userOrgMap.put(JsonKey.ORGANISATION_ID, refOrgId);
  userOrgMap.put(JsonKey.ID , USER_ID);

  operation.insertRecord(userOrgdbInfo.getKeySpace(), userOrgdbInfo.getTableName(), userOrgMap);

}
 
开发者ID:project-sunbird,项目名称:sunbird-lms-mw,代码行数:42,代码来源:BulkUploadManagementActorTest.java


注:本文中的org.sunbird.helper.ServiceFactory.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。