package com.perforce.spark.search;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import com.perforce.spark.artifact.ArtifactFactory;
import com.perforce.spark.artifact.ArtifactType;
import com.perforce.spark.artifact.ResultInterface;
public class ResultsModel {
private final List<ResultInterface> list = new ArrayList<>();
private final List<String> title = new ArrayList<>();
public ResultsModel(SearchResults results, ArtifactType type) {
if (results == null || results.getPayload() == null) {
return;
}
for (ResultDetailed r : results.getPayload().getDetailedFilesModels()) {
ResultInterface row = ArtifactFactory.getResult(type, r);
if (row.getLink() != null && !list.contains(row)) {
list.add(row);
}
}
if (!list.isEmpty()) {
Set<String> keys = list.get(0).getRow().keySet();
title.addAll(keys);
}
}
public List<ResultInterface> getList() {
return list;
}
public List<String> getTitle() {
return title;
}
}