Browse Source

Merge pull request #403 in DESIGN/design from ~ALEX.SUNG/design:feature/10.0 to feature/10.0

REPORT-6453 alphafine整合小帆

* commit 'cb32d0b3ec1137dd5d1470cc580003f0291388bb':
  提升代码质量
research/10.0
Alex.Sung 6 years ago
parent
commit
2d9e2f6c82
  1. 23
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java
  2. 13
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java
  3. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java
  4. 19
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java
  5. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java
  6. 18
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java

23
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineHelper.java

@ -5,12 +5,17 @@ import com.fr.design.actions.help.alphafine.AlphaFineConfigManager;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel;
import com.fr.design.mainframe.alphafine.cell.model.NoResultModel;
import com.fr.design.mainframe.alphafine.cell.model.RobotModel;
import com.fr.design.mainframe.alphafine.component.AlphaFineDialog;
import com.fr.design.mainframe.alphafine.model.SearchResult;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecentSearchManager;
import com.fr.design.mainframe.alphafine.search.manager.impl.RecommendSearchManager;
import com.fr.general.ProcessCanceledException;
import com.fr.json.JSONArray;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.json.JSONUtils;
import com.fr.stable.StringUtils;
import java.util.List;
@ -97,5 +102,23 @@ public class AlphaFineHelper {
return filterResult;
}
public static SearchResult getModelListFromJSONArray(String result, String keyword) throws ClassCastException, JSONException {
SearchResult allModelList = new SearchResult();
JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result);
for (int i = 0; i < jsonArray.length(); i++) {
AlphaFineHelper.checkCancel();
JSONObject jsonObject = jsonArray.optJSONObject(i);
String temp = jsonObject.optString(keyword);
if (StringUtils.isNotEmpty(temp)) {
RobotModel robotModel = new RobotModel(temp, null);
if (!allModelList.contains(robotModel)) {
allModelList.add(robotModel);
}
}
}
return allModelList;
}
}

13
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/cell/model/RobotModel.java

@ -7,6 +7,7 @@ import com.fr.general.http.HttpClient;
import com.fr.json.JSONException;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.AssistUtils;
import org.apache.commons.codec.digest.DigestUtils;
@ -92,4 +93,16 @@ public class RobotModel extends AlphaCellModel {
FineLoggerFactory.getLogger().error(e.getMessage());
}
}
@Override
public final boolean equals(Object obj) {
return obj instanceof RobotModel
&& AssistUtils.equals(this.title, ((RobotModel)obj).title)
&& AssistUtils.equals(this.content, ((RobotModel) obj).content);
}
@Override
public int hashCode() {
return AssistUtils.hashCode(title, content);
}
}

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineDialog.java

@ -1333,7 +1333,7 @@ public class AlphaFineDialog extends UIDialog {
*/
private void initBackPane() {
backPane = new JPanel(new BorderLayout());
JLabel jLabel = new JLabel(com.fr.design.i18n.Toolkit.i18nText(" < " + "Fine-Design_Report_AlphaFine_Back"));
JLabel jLabel = new JLabel(" < " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Back"));
jLabel.setPreferredSize(new Dimension(680, 20));
jLabel.setFont(AlphaFineConstants.SMALL_FONT);
jLabel.setForeground(AlphaFineConstants.DARK_GRAY);

19
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java

@ -50,23 +50,8 @@ public class ComplementAdviceManager {
try {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result);
if(jsonArray != null){
for (int i = 0; i < jsonArray.length(); i++) {
AlphaFineHelper.checkCancel();
JSONObject jsonObject = jsonArray.optJSONObject(i);
String temp = jsonObject.optString("keywords");
if (StringUtils.isNotEmpty(temp)) {
RobotModel robotModel = new RobotModel(temp, null);
if (!AlphaFineHelper.getFilterResult().contains(robotModel) && !allModelList.contains(robotModel)) {
allModelList.add(robotModel);
}
}
}
}
} catch (JSONException e) {
allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"keywords");
} catch(ClassCastException | JSONException e){
FineLoggerFactory.getLogger().error("complement advice search error: " + e.getMessage());
} catch (IOException e1) {
FineLoggerFactory.getLogger().error("complement advice get result error: " + e1.getMessage());

6
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java

@ -193,7 +193,11 @@ public class RecommendSearchManager implements AlphaFineSearchProvider {
}
public List<AlphaCellModel> getRecommendModelList() {
return recommendModelList;
SearchResult result = new SearchResult();
result.addAll(recommendModelList);
result.addAll(modelList);
result.addAll(moreModelList);
return result;
}
}

18
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManeger.java

@ -15,6 +15,8 @@ import com.fr.json.JSONObject;
import com.fr.json.JSONUtils;
import com.fr.log.FineLoggerFactory;
import java.io.IOException;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.codec.digest.DigestUtils;
/**
@ -47,20 +49,8 @@ public class SimilarSearchManeger implements AlphaFineSearchProvider {
try {
String result = HttpToolbox.get(url);
AlphaFineHelper.checkCancel();
JSONArray jsonArray = (JSONArray)JSONUtils.jsonDecode(result);
if(jsonArray != null){
if (jsonArray.length() != 0) {
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.optJSONObject(i);
String title = jsonObject.optString("title");
RobotModel robotModel = new RobotModel(title, null);
if (!AlphaFineHelper.getFilterResult().contains(robotModel) && !allModelList.contains(robotModel)) {
allModelList.add(robotModel);
}
}
}
}
} catch (JSONException e) {
allModelList = AlphaFineHelper.getModelListFromJSONArray(result,"title");
} catch (ClassCastException | JSONException e) {
FineLoggerFactory.getLogger().error("similar search error: " + e.getMessage());
} catch (IOException e) {
FineLoggerFactory.getLogger().error("similar search get result error: " + e.getMessage());

Loading…
Cancel
Save