Example #1
0
  @Override
  protected BaseModel<?> addBaseModelWithClassType(
      BaseModel<?> parentBaseModel, String keywords, ServiceContext serviceContext)
      throws Exception {

    if (_ddmStructure == null) {
      _ddmStructure =
          DDMStructureTestUtil.addStructure(
              serviceContext.getScopeGroupId(), JournalArticle.class.getName());
    }

    if (_ddmTemplate == null) {
      _ddmTemplate =
          DDMTemplateTestUtil.addTemplate(
              serviceContext.getScopeGroupId(), _ddmStructure.getStructureId());
    }

    String content = DDMStructureTestUtil.getSampleStructuredContent();

    return JournalTestUtil.addArticleWithXMLContent(
        serviceContext.getScopeGroupId(),
        content,
        _ddmStructure.getStructureKey(),
        _ddmTemplate.getTemplateKey());
  }
Example #2
0
  protected JournalArticle addArticle(long groupId, Date displayDate, int when, boolean approved)
      throws Exception {

    Map<Locale, String> titleMap = new HashMap<Locale, String>();

    titleMap.put(LocaleUtil.getDefault(), ServiceTestUtil.randomString());

    Map<Locale, String> descriptionMap = new HashMap<Locale, String>();

    descriptionMap.put(LocaleUtil.getDefault(), ServiceTestUtil.randomString());

    String content = DDMStructureTestUtil.getSampleStructuredContent();

    String xsd = DDMStructureTestUtil.getSampleStructureXSD();

    DDMStructure ddmStructure =
        DDMStructureTestUtil.addStructure(groupId, JournalArticle.class.getName(), xsd);

    DDMTemplate ddmTemplate =
        DDMTemplateTestUtil.addTemplate(groupId, ddmStructure.getStructureId());

    Calendar displayDateCalendar = getCalendar(displayDate, when);

    ServiceContext serviceContext = ServiceTestUtil.getServiceContext(groupId);

    if (approved) {
      serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);
    } else {
      serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
    }

    return JournalArticleLocalServiceUtil.addArticle(
        TestPropsValues.getUserId(),
        groupId,
        JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID,
        JournalArticleConstants.CLASSNAME_ID_DEFAULT,
        0,
        StringPool.BLANK,
        true,
        JournalArticleConstants.VERSION_DEFAULT,
        titleMap,
        descriptionMap,
        content,
        "general",
        ddmStructure.getStructureKey(),
        ddmTemplate.getTemplateKey(),
        null,
        displayDateCalendar.get(Calendar.MONTH),
        displayDateCalendar.get(Calendar.DAY_OF_MONTH),
        displayDateCalendar.get(Calendar.YEAR),
        displayDateCalendar.get(Calendar.HOUR_OF_DAY),
        displayDateCalendar.get(Calendar.MINUTE),
        0,
        0,
        0,
        0,
        0,
        true,
        0,
        0,
        0,
        0,
        0,
        true,
        true,
        false,
        null,
        null,
        null,
        null,
        serviceContext);
  }