|
|
@@ -1,20 +1,12 @@
|
|
|
package com.uas.search.console.controller;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
import org.apache.log4j.Logger;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
-import com.uas.search.console.dao.BrandSimpleInfoDao;
|
|
|
-import com.uas.search.console.dao.ComponentSimpleInfoDao;
|
|
|
-import com.uas.search.console.dao.KindSimpleInfoDao;
|
|
|
import com.uas.search.console.dcn.DCNRegistrationManager;
|
|
|
-import com.uas.search.console.model.BrandSimpleInfo;
|
|
|
-import com.uas.search.console.model.ComponentSimpleInfo;
|
|
|
-import com.uas.search.console.model.KindSimpleInfo;
|
|
|
import com.uas.search.console.service.IndexService;
|
|
|
|
|
|
/**
|
|
|
@@ -38,14 +30,14 @@ public class IndexController {
|
|
|
/**
|
|
|
* 创建索引
|
|
|
*
|
|
|
- * @param componentDataSource
|
|
|
- * 器件数据的来源,为1表示从数据库获取,为null或其他值表示从本地文件获取
|
|
|
+ * @param fromDB
|
|
|
+ * 器件数据的来源是否为数据库,为1表示从数据库获取,为null或其他值表示从本地文件获取
|
|
|
* @return 所用时间 ms
|
|
|
*/
|
|
|
@RequestMapping("/create")
|
|
|
@ResponseBody
|
|
|
- public String createIndexes(Integer componentDataSource) {
|
|
|
- return "Indexes created success in " + indexService.createIndexes(componentDataSource) + " ms.";
|
|
|
+ public String createIndexes(Integer fromDB) {
|
|
|
+ return "Indexes created success in " + indexService.createIndexes(fromDB) + " ms.";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -56,63 +48,48 @@ public class IndexController {
|
|
|
@RequestMapping("/realTimeUpdate")
|
|
|
@ResponseBody
|
|
|
public String registerDatabaseChangeNotification() {
|
|
|
- dcnRegistrationManager.registerDataChangeNotification();
|
|
|
- return "Started real-time updating for lucene index...";
|
|
|
- }
|
|
|
-
|
|
|
- @RequestMapping("/downloadComponentData")
|
|
|
- @ResponseBody
|
|
|
- public String downloadComponentData() {
|
|
|
- Long size = indexService.downloadComponentData();
|
|
|
- logger.info("Downloading finished, components' size " + size);
|
|
|
- return "Components' size: " + size;
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ComponentSimpleInfoDao componentDao;
|
|
|
-
|
|
|
- @RequestMapping("/rowTest/component")
|
|
|
- @ResponseBody
|
|
|
- public String testROWIDComponent() {
|
|
|
- System.out.println(componentDao.findByRowid("AACu7GAAEAAOZvTAAA"));
|
|
|
- return "created";
|
|
|
- }
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private BrandSimpleInfoDao brandDao;
|
|
|
-
|
|
|
- @RequestMapping("/rowTest/brand")
|
|
|
- @ResponseBody
|
|
|
- public String testROWIDBrand() {
|
|
|
- System.out.println(brandDao.findByRowid("AACoH2AAEAANmqSAAB"));
|
|
|
- return "created";
|
|
|
+ return dcnRegistrationManager.registerDataChangeNotification();
|
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
- private KindSimpleInfoDao kindDao;
|
|
|
-
|
|
|
- @RequestMapping("/rowTest/kind")
|
|
|
+ /**
|
|
|
+ * 开启实时更新索引的程序
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/realTimeUpdate/start")
|
|
|
@ResponseBody
|
|
|
- public String testROWIDKind() {
|
|
|
- System.out.println(kindDao.findByRowid("AACmtMAAEAAFmG8AAY"));
|
|
|
- return "created";
|
|
|
+ public String startRegisterDatabaseChangeNotification() {
|
|
|
+ return dcnRegistrationManager.registerDataChangeNotification();
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/findAll/kind")
|
|
|
+ /**
|
|
|
+ * 关闭实时更新索引的程序
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/realTimeUpdate/stop")
|
|
|
@ResponseBody
|
|
|
- public List<KindSimpleInfo> findAllKinds() {
|
|
|
- return kindDao.findAll();
|
|
|
+ public String unregisterDatabaseChangeNotification() {
|
|
|
+ return dcnRegistrationManager.unregisterDataChangeNotification();
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/findAll/brand")
|
|
|
+ /**
|
|
|
+ * 重启实时更新索引的程序
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping("/realTimeUpdate/restart")
|
|
|
@ResponseBody
|
|
|
- public List<BrandSimpleInfo> findAllBrands() {
|
|
|
- return brandDao.findAll();
|
|
|
+ public String restartRegisterDatabaseChangeNotification() {
|
|
|
+ dcnRegistrationManager.unregisterDataChangeNotification();
|
|
|
+ return dcnRegistrationManager.registerDataChangeNotification();
|
|
|
}
|
|
|
|
|
|
- @RequestMapping("/findAll/component")
|
|
|
+ @RequestMapping("/downloadComponentData")
|
|
|
@ResponseBody
|
|
|
- public List<ComponentSimpleInfo> findAllComponents() {
|
|
|
- return componentDao.findAll();
|
|
|
+ public String downloadComponentData() {
|
|
|
+ Long size = indexService.downloadComponentData();
|
|
|
+ logger.info("Downloading finished, components' size " + size);
|
|
|
+ return "Components' size: " + size;
|
|
|
}
|
|
|
}
|