Commit b59596b4 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

new urls for a plugin always are in the end of urls

parent 066093c4
......@@ -60,7 +60,8 @@ public class Plugin implements Serializable {
@ElementCollection
@CollectionTable(name = "plugin_urls", joinColumns = @JoinColumn(name = "plugin_id"))
@Column(name = "url")
private Set<String> urls = new HashSet<>();
@OrderBy("idx")
private List<String> urls = new ArrayList<>();
public String getHash() {
return hash;
......@@ -70,14 +71,10 @@ public class Plugin implements Serializable {
this.hash = hash;
}
public Set<String> getUrls() {
public List<String> getUrls() {
return urls;
}
public void setUrls(Set<String> urls) {
this.urls = urls;
}
public String getName() {
return name;
}
......
alter table plugin_urls add column idx integer;
alter table plugin_urls add column idx_c varchar;
update plugin_urls set idx_c = ctid;
update plugin_urls p1 set idx = (select count(*) from plugin_urls p2 where p2.idx_c < p1.idx_c);
alter table plugin_urls drop column idx_c;
alter table plugin_urls alter COLUMN idx set not null;
CREATE SEQUENCE plugin_url_sequence;
alter table plugin_urls alter COLUMN idx set default nextval('plugin_url_sequence');
SELECT setval('plugin_url_sequence', (select max(idx)+1 from plugin_urls));
\ No newline at end of file
......@@ -57,9 +57,8 @@ public class PluginRestImpl extends BaseRestImpl {
result.put("name", plugin.getName());
result.put("version", plugin.getVersion());
result.put("isPublic", plugin.isPublic());
List<String> urls = new ArrayList<>(plugin.getUrls());
Collections.sort(urls);
result.put("urls", urls);
plugin.getUrls().contains("");
result.put("urls", plugin.getUrls());
return result;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment