@Override
  public List<OrderProcessModel> findProcessesByActionIds(
      final String processName, final String processCurrentActions[]) {
    final String query =
        "select {bp.PK} "
            + "from {OrderProcess AS bp  JOIN ProcessTask AS pt ON {bp.pk} = {pt.process} } "
            + "WHERE {bp.processDefinitionName} = ?processDefinitionName and {pt.action} in (?processCurrentActions)";

    final FlexibleSearchQuery searchQuery = new FlexibleSearchQuery(query);
    searchQuery.addQueryParameter("processDefinitionName", processName);
    searchQuery.addQueryParameter("processCurrentActions", Arrays.asList(processCurrentActions));
    final SearchResult<OrderProcessModel> processes = flexibleSearchService.search(searchQuery);
    return processes.getResult();
  }
Esempio n. 2
0
 @Override
 public List<CourseModel> findCourseByCode(final String code) {
   validateParameterNotNull(code, "Product code must not be null!");
   final Map<String, Object> params = new HashMap<String, Object>();
   params.put("code", code);
   final SearchResult<CourseModel> result = flexibleSearchService.search(COURSES_BY_CODE, params);
   return result.getResult();
 }
Esempio n. 3
0
 /*
  * (non-Javadoc)
  *
  * @see org.training.dao.TrainingDao#getAllCoursesByTraining()
  */
 @Override
 public List<CourseModel> getAllCoursesByTraining(final String code) {
   final Map<String, Object> params = new HashMap<String, Object>();
   params.put("code", code);
   final SearchResult<CourseModel> result =
       flexibleSearchService.search(COURSES_BY_TRAINING, params);
   return result.getResult();
 }
 @Override
 public List<OrderModel> findAllOrdersInStatus(final OrderStatus orderStatus) {
   final String query =
       "SELECT {pk} FROM {Order} WHERE  {status} = ?status AND {versionID} IS NULL";
   final FlexibleSearchQuery searchQuery = new FlexibleSearchQuery(query);
   searchQuery.addQueryParameter("status", orderStatus);
   final SearchResult<OrderModel> orderList = flexibleSearchService.search(searchQuery);
   return orderList.getResult();
 }
  protected MultipleCatalogsSyncCronJobModel getCronJobIfExists(final String catalog) {
    final MultipleCatalogsSyncCronJobModel example = new MultipleCatalogsSyncCronJobModel();
    example.setCode(catalog + CRON_JOB_SUBFIX);

    final MultipleCatalogsSyncCronJobModel cronJobModel =
        flexibleSearchService.getModelByExample(example);

    Preconditions.checkNotNull(cronJobModel);

    return cronJobModel;
  }
  @SocketEvent(socketId = "mail")
  public void displaySearchresult(MailInternalData mailData) {

    FlexibleSearchQuery query =
        new FlexibleSearchQuery(
            "Select {pk} from {EmailPage} where {uid}='" + mailData.getUid() + "'");
    SearchResult<EmailPageModel> searhResult = flexibleSearchService.search(query);
    final EmailPageModel emailPageModel = searhResult.getResult().get(0);

    FlexibleSearchQuery querybm =
        new FlexibleSearchQuery(
            "Select {pk} from {BusinessProcess } where {code}='"
                + mailData.getBusinessOrderCode()
                + "'");
    SearchResult<BusinessProcessModel> searhResultBs = flexibleSearchService.search(querybm);
    final BusinessProcessModel businessProcessModel = searhResultBs.getResult().get(0);

    final EmailPageTemplateModel emailPageTemplateModel =
        (EmailPageTemplateModel) emailPageModel.getMasterTemplate();
    currentBodyRenderTemplate = emailPageTemplateModel.getHtmlTemplate();
    currentEmailContext =
        this.executeInContext(
            new ImpersonationService.Executor<
                AbstractEmailContext<BusinessProcessModel>, RuntimeException>() {
              @Override
              public AbstractEmailContext<BusinessProcessModel> execute() throws RuntimeException {
                return emailContextFactory.create(
                    businessProcessModel, emailPageModel, currentBodyRenderTemplate);
              }
            });

    final StringWriter body = new StringWriter();
    rendererService.render(currentBodyRenderTemplate, currentEmailContext, body);
    html.setContent(body.toString());
    // label.setValue(emailPageTemplateModel.getHtmlTerendererServicemplate().getTemplateScript());
    VmEmailTemplateData vmData = new VmEmailTemplateData();
    vmData.setBody(emailPageTemplateModel.getHtmlTemplate().getTemplateScript());
    this.sendOutput("selectVmTemplate", vmData);
  }
 @Test
 public void getLeadTimeDataTest() {
   List<EnergizerB2BUnitLeadTimeModel> models = new ArrayList<EnergizerB2BUnitLeadTimeModel>();
   final String productQuery = "Query to get data from DB";
   final String modelData = "TestUnit";
   final String shippingpoint = "SHIP01";
   final String soldToAddressId = "1111";
   final EnergizerB2BUnitModel b2bUnitModel = new EnergizerB2BUnitModel();
   final FlexibleSearchQuery query = new FlexibleSearchQuery(productQuery);
   Mockito.when(flexibleSearchService.<EnergizerB2BUnitLeadTimeModel>search(query).getResult())
       .thenReturn((models));
   models = energizerB2BOrderDAO.getLeadTimeData(b2bUnitModel, shippingpoint, soldToAddressId);
   Assert.assertNotNull(models);
 }
  @Test
  public void testIfAggregatedStatisticsAreSavedToDb() {
    // given
    final Date date1 =
        new DateTime()
            .withYear(2011)
            .withMonthOfYear(10)
            .withDayOfMonth(15)
            .withHourOfDay(12)
            .withMinuteOfHour(20)
            .toDate();
    final Date date2 =
        new DateTime()
            .withYear(2011)
            .withMonthOfYear(10)
            .withDayOfMonth(15)
            .withHourOfDay(12)
            .withMinuteOfHour(45)
            .toDate();
    final Date date3 =
        new DateTime()
            .withYear(2011)
            .withMonthOfYear(11)
            .withDayOfMonth(19)
            .withHourOfDay(12)
            .withMinuteOfHour(45)
            .toDate();
    final List<AggregatedSearchQueryInfo> aggrResults = new ArrayList<AggregatedSearchQueryInfo>();
    aggrResults.add(new AggregatedSearchQueryInfo(SOLR_CONFIG_NAME, "monitor", "en", 5, date1));
    aggrResults.add(new AggregatedSearchQueryInfo(SOLR_CONFIG_NAME, "monitor lcd", "en", 3, date2));
    aggrResults.add(new AggregatedSearchQueryInfo(SOLR_CONFIG_NAME, "canon", "en", 2, date3));

    Mockito.when(mockSolrQueryStatisticsAggregator.aggregate()).thenReturn(aggrResults);

    solrQueryStatisticsCollectorJob.setSolrQueryStatisticsAggregator(
        mockSolrQueryStatisticsAggregator);

    // when
    final PerformResult perform = solrQueryStatisticsCollectorJob.perform(null);

    // then
    org.fest.assertions.Assertions.assertThat(perform.getResult()).isEqualTo(CronJobResult.SUCCESS);
    org.fest.assertions.Assertions.assertThat(perform.getStatus())
        .isEqualTo(CronJobStatus.FINISHED);

    final SearchResult<SolrQueryAggregatedStatsModel> result =
        flexibleSearchService.search("SELECT {PK} FROM {SolrQueryAggregatedStats}");
    org.fest.assertions.Assertions.assertThat(result.getResult()).hasSize(3);
  }
  @Test
  public void testDisableCollectingStatistics() {
    // given
    solrQueryStatisticsCollectorJob.setEnableCollectingStatistics(false);

    // when
    final PerformResult perform = solrQueryStatisticsCollectorJob.perform(null);

    // then
    org.fest.assertions.Assertions.assertThat(perform.getResult()).isEqualTo(CronJobResult.SUCCESS);
    org.fest.assertions.Assertions.assertThat(perform.getStatus())
        .isEqualTo(CronJobStatus.FINISHED);

    final SearchResult<SolrQueryAggregatedStatsModel> result =
        flexibleSearchService.search("SELECT {PK} FROM {SolrQueryAggregatedStats}");
    org.fest.assertions.Assertions.assertThat(result.getResult()).isEmpty();
  }
  public List<OrderProcessModel> findAllProcessModelsToRepair(
      final String processName, final String endMessage) {
    final String query =
        "select {PK} from {OrderProcess} WHERE {"
            + BusinessProcess.PROCESSDEFINITIONNAME
            + "} = ?processDefinitionName "
            + "and {"
            + BusinessProcess.STATE
            + "} = ?statusValue and {"
            + BusinessProcess.ENDMESSAGE
            + "} = ?processResult";

    final FlexibleSearchQuery searchQuery = new FlexibleSearchQuery(query);
    searchQuery.addQueryParameter("processDefinitionName", processName);
    searchQuery.addQueryParameter("processResult", endMessage);
    searchQuery.addQueryParameter("statusValue", ProcessState.ERROR);
    final SearchResult<OrderProcessModel> processes = flexibleSearchService.search(searchQuery);
    return processes.getResult();
  }
  @Test
  public void testIfErrorDuringPerformance() {
    // given
    Mockito.when(mockSolrQueryStatisticsAggregator.aggregate()).thenThrow(new RuntimeException());
    solrQueryStatisticsCollectorJob.setSolrQueryStatisticsAggregator(
        mockSolrQueryStatisticsAggregator);

    TestUtils.disableFileAnalyzer("test for an error during job execution");
    // when
    final PerformResult perform = solrQueryStatisticsCollectorJob.perform(null);

    TestUtils.enableFileAnalyzer();

    // then
    org.fest.assertions.Assertions.assertThat(perform.getResult()).isEqualTo(CronJobResult.ERROR);
    org.fest.assertions.Assertions.assertThat(perform.getStatus())
        .isEqualTo(CronJobStatus.FINISHED);

    final SearchResult<SolrQueryAggregatedStatsModel> result =
        flexibleSearchService.search("SELECT {PK} FROM {SolrQueryAggregatedStats}");
    org.fest.assertions.Assertions.assertThat(result.getResult()).isEmpty();
  }
  @Before
  public void beforeTest() throws Exception {
    MockitoAnnotations.initMocks(this);
    // inject a mock payment provider
    cardPaymentService.setCommandFactoryRegistry(mockupCommandFactoryRegistry);
    paymentService.setCardPaymentService(cardPaymentService);
    commerceCheckoutService.setPaymentService(paymentService);

    createCoreData();
    createDefaultCatalog();

    importCsv("/energizercore/test/testOrganizations.csv", "utf-8");
    importCsv("/energizercore/test/testB2BCommerceCart.csv", "utf-8");

    final CartModel modelByExample = new CartModel();
    modelByExample.setCode("dc_shhCart_b2bas");

    final CartModel cart = flexibleSearchService.getModelByExample(modelByExample);
    Assert.assertNotNull(cart);
    cartService.setSessionCart(cart);
    userService.setCurrentUser(cart.getUser());

    if (flexibleSearchService
        .search(
            "SELECT {"
                + ServicelayerJobModel.PK
                + "} FROM {"
                + ServicelayerJobModel._TYPECODE
                + "} WHERE "
                + "{"
                + ServicelayerJobModel.SPRINGID
                + "}=?springid",
            Collections.singletonMap("springid", "b2bAcceleratorCartToOrderJob"))
        .getResult()
        .isEmpty()) {
      final ServicelayerJobModel servicelayerJobModel =
          modelService.create(ServicelayerJobModel.class);
      servicelayerJobModel.setCode("b2bAcceleratorCartToOrderJob");
      servicelayerJobModel.setSpringId("b2bAcceleratorCartToOrderJob");
      modelService.save(servicelayerJobModel);
    }

    final Date startDate = new Date();
    final Integer day = Integer.valueOf(5);
    final Integer week = Integer.valueOf(2);
    final List<DayOfWeek> days = new ArrayList<DayOfWeek>();
    days.add(DayOfWeek.TUESDAY);
    days.add(DayOfWeek.FRIDAY);
    triggerModel = modelService.create(TriggerModel.class);
    triggerModel.setRelative(Boolean.TRUE);
    triggerModel.setActivationTime(startDate);
    triggerModel.setDay(day);
    triggerModel.setWeekInterval(week);
    triggerModel.setDaysOfWeek(days);

    cartToOrderCronJob = modelService.create(CartToOrderCronJobModel.class);
    cartToOrderCronJob.setCart(cartService.getSessionCart());
    cartToOrderCronJob.setDeliveryAddress(userService.getCurrentUser().getDefaultShipmentAddress());
    cartToOrderCronJob.setPaymentAddress(userService.getCurrentUser().getDefaultPaymentAddress());
    cartToOrderCronJob.setPaymentInfo(cartService.getSessionCart().getPaymentInfo());
    setCronJobToTrigger(cartToOrderCronJob, Collections.singletonList(triggerModel));
    cartToOrderCronJob.setJob(cronJobService.getJob("b2bAcceleratorCartToOrderJob"));
    modelService.save(cartToOrderCronJob);
    final BaseSiteModel site = baseSiteService.getBaseSiteForUID("b2bstoretemplate");
    Assert.assertNotNull("no site found for id 'site'", site);
    baseSiteService.setCurrentBaseSite(site, false);
  }
Esempio n. 13
0
 /*
  * (non-Javadoc)
  *
  * @see org.training.dao.TrainingDao#getAllTraining()
  */
 @Override
 public List<TrainingModel> getAllTraining() {
   final SearchResult<TrainingModel> result = flexibleSearchService.search(ALL_TRAININGS);
   return result.getResult();
 }
Esempio n. 14
0
 /*
  * (non-Javadoc)
  *
  * @see org.training.dao.TrainingDao#getAllCourses()
  */
 @Override
 public List<CourseModel> getAllCourses() {
   final SearchResult<CourseModel> result = flexibleSearchService.search(ALL_COURSES);
   return result.getResult();
 }