Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/issue172 slide #455

Merged
merged 9 commits into from
Sep 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@
<artifactId>lucene-highlighter</artifactId>
<version>4.10.2</version>
</dependency>

<dependency>
<groupId>org.apache.tika</groupId>
<artifactId>tika-parsers</artifactId>
<version>1.9</version>
<version>1.12</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
Expand Down Expand Up @@ -166,6 +165,13 @@
<version>4.3.1</version>
</dependency>

<dependency>
<groupId>com.kenai.nbpwr</groupId>
<artifactId>com-sun-pdfview</artifactId>
<version>1.0.5-201003191900</version>
<type>nbm</type>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.support.project.knowledge.logic.CrawlerLogic;
import org.support.project.knowledge.logic.IndexLogic;
import org.support.project.knowledge.logic.KnowledgeLogic;
import org.support.project.knowledge.logic.SlideLogic;
import org.support.project.knowledge.logic.TargetLogic;
import org.support.project.knowledge.parser.Parser;
import org.support.project.knowledge.parser.ParserFactory;
Expand All @@ -50,6 +51,7 @@ public class FileParseBat extends AbstractBat {
public static final int PARSE_STATUS_PARSING = 1;
public static final int PARSE_STATUS_ERROR_FINISHED = -100;
public static final int PARSE_STATUS_PARSED = 100;
public static final int PARSE_STATUS_SLIDE_PARSED = 101;

public static final int PARSE_STATUS_NO_TARGET = -1;

Expand Down Expand Up @@ -80,6 +82,11 @@ private void start() throws Exception {
crawl();
}


/**
* 情報の種別がBookmarkの場合に、URLに書かれているページのテキストを取得し検索可能にする
* @throws Exception
*/
private void crawl() throws Exception {
KnowledgeItemValuesDao itemValuesDao = KnowledgeItemValuesDao.get();
List<KnowledgeItemValuesEntity> itemValues = itemValuesDao.selectOnTypeIdAndItemNoAndStatus(TemplateMastersDao.TYPE_ID_BOOKMARK,
Expand Down Expand Up @@ -153,6 +160,13 @@ private void crawl() throws Exception {
}
}

/**
* 添付したファイルの中身を抽出する
* @throws FileNotFoundException
* @throws IOException
* @throws MimeTypeException
* @throws Exception
*/
private void fileParse() throws FileNotFoundException, IOException, MimeTypeException, Exception {
KnowledgeFilesDao filesDao = KnowledgeFilesDao.get();
IndexLogic indexLogic = IndexLogic.get();
Expand Down Expand Up @@ -251,7 +265,11 @@ private void fileParse() throws FileNotFoundException, IOException, MimeTypeExce

// パースステータスをパース完了に変更(もしパースでエラーが発生しても、次回から対象外になる)
filesDao.changeStatus(entity.getFileNo(), PARSE_STATUS_PARSED, UPDATE_USER_ID);

boolean slideParse = SlideLogic.get().parseSlide(tmp, knowledgeFilesEntity);
if (slideParse) {
// スライドのパース済のステータスへ
filesDao.changeStatus(entity.getFileNo(), PARSE_STATUS_SLIDE_PARSED, UPDATE_USER_ID);
}
} catch (Exception e) {
// パースの解析でなんらかのエラー
filesDao.changeStatus(entity.getFileNo(), PARSE_STATUS_ERROR_FINISHED, UPDATE_USER_ID);
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/org/support/project/knowledge/config/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public static AppConfig get() {

private boolean convIndexPath = false;

private String slidePath;

private boolean convSlidePath = false;


/**
* @return the indexPath
*/
Expand All @@ -40,5 +45,30 @@ public String getIndexPath() {
public void setIndexPath(String indexPath) {
this.indexPath = indexPath;
}

/**
* Get slidePath
* @return the slidePath
*/
public String getSlidePath() {
if (StringUtils.isEmpty(slidePath)) {
return "";
}

if (!convSlidePath) {
String path = slidePath;
this.slidePath = convPath(path);
convSlidePath = true;
}
return slidePath;
}

/**
* Set slidePath
* @param slidePath the slidePath to set
*/
public void setSlidePath(String slidePath) {
this.slidePath = slidePath;
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
package org.support.project.knowledge.control.open;

import java.io.FileNotFoundException;

import org.support.project.common.log.Log;
import org.support.project.common.log.LogFactory;
import org.support.project.di.DI;
import org.support.project.di.Instance;
import org.support.project.knowledge.control.Control;
import org.support.project.knowledge.entity.KnowledgeFilesEntity;
import org.support.project.knowledge.logic.SlideLogic;
import org.support.project.knowledge.logic.UploadedFileLogic;
import org.support.project.knowledge.vo.SlideInfo;
import org.support.project.web.bean.DownloadInfo;
import org.support.project.web.boundary.Boundary;
import org.support.project.web.common.HttpStatus;
import org.support.project.web.control.service.Get;
import org.support.project.web.exception.InvalidParamException;

@DI(instance = Instance.Prototype)
public class FileControl extends Control {
Expand All @@ -24,11 +30,38 @@ public Boundary download() {

Long fileNo = getParam("fileNo", Long.class);
KnowledgeFilesEntity entity = fileLogic.getFile(fileNo, getLoginedUser());

if (entity == null) {
return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND");
}

return download(entity.getFileName(), entity.getFileBinary(), entity.getFileSize().longValue());
}

@Get
public Boundary slide() throws InvalidParamException, FileNotFoundException {
String[] pathInfos = getPathInfos();
if (pathInfos == null || pathInfos.length == 0) {
return send(HttpStatus.SC_400_BAD_REQUEST);
}
String fileNo = pathInfos[0];
String slideImage = null;
if (pathInfos.length > 1) {
slideImage = pathInfos[1];
}
if (slideImage == null) {
// スライドの情報を取得
SlideInfo slideInfo = SlideLogic.get().getSlideInfo(fileNo, getLoginedUser());
if (slideInfo == null) {
return sendError(HttpStatus.SC_404_NOT_FOUND, "NOT FOUND");
}
return send(slideInfo);
} else {
// スライドの画像を取得
DownloadInfo down = SlideLogic.get().getSlideImage(fileNo, slideImage, getLoginedUser());
if (down == null) {
return sendError(HttpStatus.SC_404_NOT_FOUND, "Not Found");
}
return download(down);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public static KnowledgeFilesDao get() {
public List<KnowledgeFilesEntity> selectOnKnowledgeId(Long knowledgeId) {
StringBuilder sql = new StringBuilder();
sql.append(
"SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, FILE_NAME, FILE_SIZE, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ");
"SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, FILE_NAME, FILE_SIZE, PARSE_STATUS, "
+ "INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ");
sql.append("FROM KNOWLEDGE_FILES WHERE KNOWLEDGE_ID = ?;");
return executeQueryList(sql.toString(), KnowledgeFilesEntity.class, knowledgeId);
}
Expand All @@ -50,7 +51,8 @@ public List<KnowledgeFilesEntity> selectOnKnowledgeId(Long knowledgeId) {
public KnowledgeFilesEntity selectOnKeyWithoutBinary(Long fileNo) {
StringBuilder sql = new StringBuilder();
sql.append(
"SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, FILE_NAME, FILE_SIZE, INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ");
"SELECT FILE_NO, KNOWLEDGE_ID, COMMENT_NO, FILE_NAME, FILE_SIZE, PARSE_STATUS "
+ "INSERT_USER, INSERT_DATETIME, UPDATE_USER, UPDATE_DATETIME, DELETE_FLAG ");
sql.append("FROM KNOWLEDGE_FILES WHERE FILE_NO = ?;");
return executeQuerySingle(sql.toString(), KnowledgeFilesEntity.class, fileNo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.util.Map;
import java.util.TimeZone;

import javax.annotation.Nullable;

import org.support.project.common.log.Log;
import org.support.project.common.log.LogFactory;
import org.support.project.knowledge.deploy.v0_0_1.InitializeSystem;
Expand Down Expand Up @@ -56,7 +54,7 @@ public InitDB() {
MAP.put("1.6.0", Migrate_1_6_0.get());
}

public static void main(@Nullable String[] args) throws Exception {
public static void main(String[] args) throws Exception {
// 内部的には、日付はGMTとして扱う
TimeZone zone = TimeZone.getTimeZone("GMT");
TimeZone.setDefault(zone);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.support.project.knowledge.deploy.v1_6_0;

import org.support.project.knowledge.deploy.Migrate;
import org.support.project.knowledge.logic.SlideLogic;
import org.support.project.ormapping.tool.dao.InitializeDao;

public class Migrate_1_6_0 implements Migrate {
Expand All @@ -16,6 +17,8 @@ public boolean doMigrate() throws Exception {
"/org/support/project/knowledge/deploy/v1_6_0/migrate.sql",
};
initializeDao.initializeDatabase(sqlpaths);

SlideLogic.get().initSlideDir();
return true;
}
}
Loading