@Override
  protected int getNotInTrashBaseModelsCount(BaseModel<?> parentBaseModel) throws Exception {

    JournalFolder folder = (JournalFolder) parentBaseModel;

    return JournalArticleLocalServiceUtil.getNotInTrashArticlesCount(
        folder.getGroupId(), folder.getFolderId());
  }
  @Override
  protected List<? extends WorkflowedModel> getChildrenWorkflowedModels(
      BaseModel<?> parentBaseModel) throws Exception {

    JournalFolder folder = (JournalFolder) parentBaseModel;

    return JournalArticleLocalServiceUtil.getArticles(folder.getGroupId(), folder.getFolderId());
  }
  @Override
  protected void deleteParentBaseModel(BaseModel<?> parentBaseModel, boolean includeTrashedEntries)
      throws Exception {

    JournalFolder folder = (JournalFolder) parentBaseModel;

    JournalFolderServiceUtil.deleteFolder(folder.getFolderId(), false);
  }
  @Override
  public void updatedPermission(String primKey) {
    JournalFolder folder =
        _journalFolderLocalService.fetchJournalFolder(GetterUtil.getLong(primKey));

    if (folder == null) {
      return;
    }

    folder.setModifiedDate(new Date());

    _journalFolderLocalService.updateJournalFolder(folder);
  }
  @Override
  protected void doSetUp() throws Exception {
    _article =
        JournalTestUtil.addArticle(
            group.getGroupId(), RandomTestUtil.randomString(), RandomTestUtil.randomString());

    JournalFolder folder =
        JournalTestUtil.addFolder(group.getGroupId(), RandomTestUtil.randomString());

    _subarticle =
        JournalTestUtil.addArticle(
            group.getGroupId(), folder.getFolderId(),
            RandomTestUtil.randomString(), RandomTestUtil.randomString());
  }
  @Override
  protected BaseModel<?> addBaseModelWithWorkflow(
      BaseModel<?> parentBaseModel, boolean approved, ServiceContext serviceContext)
      throws Exception {

    JournalFolder folder = (JournalFolder) parentBaseModel;

    return JournalTestUtil.addArticleWithWorkflow(
        serviceContext.getScopeGroupId(),
        folder.getFolderId(),
        getSearchKeywords(),
        getSearchKeywords(),
        approved);
  }
  protected BaseModel<?> addArticleWithXmlContent(
      BaseModel<?> parentBaseModel,
      String content,
      DDMStructure ddmStructure,
      DDMTemplate ddmTemplate,
      ServiceContext serviceContext)
      throws Exception {

    _ddmStructure = ddmStructure;

    JournalFolder folder = (JournalFolder) parentBaseModel;

    return JournalTestUtil.addArticleWithXMLContent(
        folder.getFolderId(),
        content,
        ddmStructure.getStructureKey(),
        ddmTemplate.getTemplateKey(),
        serviceContext);
  }
  @Override
  protected BaseModel<?> addBaseModelWithWorkflow(
      BaseModel<?> parentBaseModel,
      boolean approved,
      String keywords,
      ServiceContext serviceContext)
      throws Exception {

    JournalFolder folder = (JournalFolder) parentBaseModel;

    long folderId = JournalFolderConstants.DEFAULT_PARENT_FOLDER_ID;

    if (folder != null) {
      folderId = folder.getFolderId();
    }

    return JournalTestUtil.addArticleWithWorkflow(
        group.getGroupId(),
        folderId,
        keywords,
        RandomTestUtil.randomString(50),
        approved,
        serviceContext);
  }