Commit c4f6c5e1 authored by Benoit Lavenier's avatar Benoit Lavenier

[fix] Add new attribute 'version' to record model fix #29

parent 2987dbd8
......@@ -30,11 +30,13 @@ import org.duniter.core.client.model.local.LocalEntity;
*/
public class Record implements LocalEntity<String> {
public static final String PROPERTY_VERSION="version";
public static final String PROPERTY_ISSUER="issuer";
public static final String PROPERTY_HASH="hash";
public static final String PROPERTY_SIGNATURE="signature";
public static final String PROPERTY_TIME="time";
private String version;
private String id;
private String issuer;
private String hash;
......@@ -45,6 +47,7 @@ public class Record implements LocalEntity<String> {
}
public Record(Record another) {
this.version = another.getVersion();
this.id = another.getId();
this.issuer = another.getIssuer();
this.hash = another.getHash();
......@@ -52,6 +55,14 @@ public class Record implements LocalEntity<String> {
this.time = another.getTime();
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
@JsonIgnore
public String getId() {
return id;
......
......@@ -28,12 +28,39 @@ package org.duniter.core.client.model.elasticsearch;
*/
public final class Records {
// Common fields
public static final String PROPERTY_ISSUER="issuer";
public static final String PROPERTY_HASH="hash";
public static final String PROPERTY_SIGNATURE="signature";
public static final String PROPERTY_VERSION="version";
public static final String PROPERTY_TIME="time";
public static final String PROPERTY_CREATION_TIME="creationTime";
// Read marker
public static final String PROPERTY_READ_SIGNATURE="read_signature";
// Location
public static final String PROPERTY_ADDRESS="address";
public static final String PROPERTY_CITY="city";
public static final String PROPERTY_GEO_POINT="geoPoint";
// record
public static final String PROPERTY_TITLE="title";
public static final String PROPERTY_DESCRIPTION="description";
// Avatar & pictures
public static final String PROPERTY_AVATAR="avatar";
public static final String PROPERTY_PICTURES="pictures";
public static final String PROPERTY_PICTURES_COUNT="picturesCount";
// Socials & tags
public static final String PROPERTY_SOCIALS="socials";
public static final String PROPERTY_TAGS="tags";
// Other
public static final String PROPERTY_CATEGORY="category";
public static final String PROPERTY_CONTENT="content";
}
......@@ -29,12 +29,14 @@ public class UserProfile extends Record {
public static final String PROPERTY_TITLE = "title";
public static final String PROPERTY_DESCRIPTION="description";
public static final String PROPERTY_ADDRESS="address";
public static final String PROPERTY_CITY="city";
public static final String PROPERTY_EMAIL="email";
public static final String PROPERTY_LOCALE="locale";
private String title;
private String description;
private String address;
private String email;
private String locale;
......@@ -69,4 +71,12 @@ public class UserProfile extends Record {
public void setLocale(String locale) {
this.locale = locale;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
}
......@@ -403,6 +403,7 @@ public class Peer implements LocalEntity<String>, Serializable {
}
public static class Stats {
public static final String PROPERTY_VERSION = "version";
public static final String PROPERTY_STATUS = "status";
public static final String PROPERTY_LAST_UP_TIME = "lastUpTime";
public static final String PROPERTY_UID = "uid";
......
......@@ -14,7 +14,7 @@
#
# Use a descriptive name for your cluster:
#
cluster.name: g1-es-data
cluster.name: g1-es-data-test
#
# ------------------------------------ Node ------------------------------------
#
......@@ -180,16 +180,14 @@ duniter.p2p.discovery.enable: false
#
duniter.p2p.includes.endpoints: [
"ES_USER_API g1.data.duniter.fr 443",
"ES_SUBSCRIPTION_API g1.data.duniter.fr 443",
"ES_USER_API g1.data.le-sou.org 443",
"ES_SUBSCRIPTION_API g1.data.le-sou.org 443"
"ES_SUBSCRIPTION_API g1.data.duniter.fr 443"
]
#
# Pass a list of pubkeys to always synchronize (default: <empty>)
#
duniter.p2p.includes.pubkeys: [
"38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE"
]
#duniter.p2p.includes.pubkeys: [
# "38MEAZN68Pz1DTvT3tqgxx4yQP6snJCQhPqEFxbDk4aE"
#]
#duniter.p2p.fullResyncAtStartup: true
#
# ---------------------------------- Duniter4j Mail module -----------------------
......
......@@ -373,7 +373,7 @@ public class PeerDaoImpl extends AbstractDao implements PeerDao {
.startObject("properties")
// stats.version
.startObject("version")
.startObject(Peer.Stats.PROPERTY_VERSION)
.field("type", "string")
.endObject()
......
......@@ -22,6 +22,7 @@ package org.duniter.elasticsearch.subscription.dao.record;
* #L%
*/
import org.duniter.core.client.model.elasticsearch.Record;
import org.duniter.core.exception.TechnicalException;
import org.duniter.core.util.CollectionUtils;
import org.duniter.elasticsearch.subscription.PluginSettings;
......@@ -86,54 +87,64 @@ public class SubscriptionRecordDaoImpl extends AbstractSubscriptionIndexTypeDao<
.startObject(getType())
.startObject("properties")
// version
.startObject(SubscriptionRecord.PROPERTY_VERSION)
.field("type", "integer")
.endObject()
// type
.startObject(SubscriptionRecord.PROPERTY_TYPE)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// issuer
.startObject("issuer")
.startObject(SubscriptionRecord.PROPERTY_ISSUER)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// recipient
.startObject("recipient")
.startObject(SubscriptionRecord.PROPERTY_RECIPIENT)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// time
.startObject("time")
.startObject(SubscriptionRecord.PROPERTY_TIME)
.field("type", "integer")
.endObject()
// nonce
.startObject("nonce")
.startObject(SubscriptionRecord.PROPERTY_NONCE)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// issuer content
.startObject("issuer_content")
// issuerContent
.startObject(SubscriptionRecord.PROPERTY_ISSUER_CONTENT)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// receiver content
.startObject("receiver_content")
.startObject(SubscriptionRecord.PROPERTY_RECIPIENT_CONTENT)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// hash
.startObject("hash")
.startObject(SubscriptionRecord.PROPERTY_HASH)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// signature
.startObject("signature")
.startObject(SubscriptionRecord.PROPERTY_SIGNATURE)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
.endObject()
.endObject().endObject();
......
......@@ -24,7 +24,9 @@ package org.duniter.elasticsearch.user.dao;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.duniter.core.client.model.elasticsearch.Record;
import org.duniter.core.client.model.elasticsearch.RecordComment;
import org.duniter.core.client.model.elasticsearch.Records;
import org.duniter.core.exception.TechnicalException;
import org.duniter.elasticsearch.dao.AbstractIndexTypeDao;
import org.duniter.elasticsearch.user.PluginSettings;
......@@ -100,19 +102,24 @@ public class AbstractCommentDaoImpl<T extends AbstractCommentDaoImpl> extends Ab
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType())
.startObject("properties")
// version
.startObject(Record.PROPERTY_VERSION)
.field("type", "integer")
.endObject()
// issuer
.startObject("issuer")
.startObject(Record.PROPERTY_ISSUER)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// creationTime
.startObject("creationTime")
.startObject(Records.PROPERTY_CREATION_TIME)
.field("type", "integer")
.endObject()
// time
.startObject("time")
.startObject(Record.PROPERTY_TIME)
.field("type", "integer")
.endObject()
......
......@@ -25,6 +25,8 @@ package org.duniter.elasticsearch.user.dao;
import com.fasterxml.jackson.core.JsonProcessingException;
import org.duniter.core.client.model.elasticsearch.Record;
import org.duniter.core.client.model.elasticsearch.Records;
import org.duniter.elasticsearch.user.model.UserProfile;
import org.duniter.core.exception.TechnicalException;
import org.duniter.core.util.ObjectUtils;
import org.duniter.elasticsearch.dao.AbstractIndexTypeDao;
......@@ -74,20 +76,25 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType())
.startObject("properties")
// version
.startObject(Record.PROPERTY_VERSION)
.field("type", "integer")
.endObject()
// title
.startObject("title")
.startObject(Records.PROPERTY_TITLE)
.field("type", "string")
.field("analyzer", stringAnalyzer)
.endObject()
// description
.startObject("description")
.startObject(Records.PROPERTY_DESCRIPTION)
.field("type", "string")
.field("analyzer", stringAnalyzer)
.endObject()
// creationTime
.startObject("creationTime")
.startObject(Records.PROPERTY_CREATION_TIME)
.field("type", "integer")
.endObject()
......@@ -115,23 +122,23 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst
.endObject()
// address
.startObject("address")
.startObject(Records.PROPERTY_ADDRESS)
.field("type", "string")
.field("analyzer", stringAnalyzer)
.endObject()
// city
.startObject("city")
.startObject(Records.PROPERTY_CITY)
.field("type", "string")
.endObject()
// geoPoint
.startObject("geoPoint")
.startObject(Records.PROPERTY_GEO_POINT)
.field("type", "geo_point")
.endObject()
// avatar
.startObject("avatar")
.startObject(Records.PROPERTY_AVATAR)
.field("type", "attachment")
.startObject("fields") // fields
.startObject("content") // content
......@@ -151,7 +158,7 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst
.endObject()
// social networks
.startObject("socials")
.startObject(Records.PROPERTY_SOCIALS)
.field("type", "nested")
.field("dynamic", "false")
.startObject("properties")
......@@ -167,7 +174,7 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst
.endObject()
// tags
.startObject("tags")
.startObject(Records.PROPERTY_TAGS)
.field("type", "completion")
.field("search_analyzer", "simple")
.field("analyzer", "simple")
......@@ -184,7 +191,7 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst
// pictures
if (isNestedPicturesEnable) {
mapping.startObject("pictures")
mapping.startObject(Records.PROPERTY_PICTURES)
.field("type", "nested")
.field("dynamic", "false")
.startObject("properties")
......@@ -212,14 +219,14 @@ public class AbstractRecordDaoImpl<T extends AbstractRecordDaoImpl> extends Abst
.endObject()
// picturesCount
.startObject("picturesCount")
.startObject(Records.PROPERTY_PICTURES_COUNT)
.field("type", "integer")
.endObject();
}
// category
if (isNestedCategoryEnable) {
mapping.startObject("category")
mapping.startObject(Records.PROPERTY_CATEGORY)
.field("type", "nested")
.field("dynamic", "false")
.startObject("properties")
......
......@@ -25,12 +25,14 @@ package org.duniter.elasticsearch.user.dao.profile;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import org.duniter.core.client.model.elasticsearch.Record;
import org.duniter.core.client.model.elasticsearch.Records;
import org.duniter.core.exception.TechnicalException;
import org.duniter.core.util.ObjectUtils;
import org.duniter.core.util.Preconditions;
import org.duniter.elasticsearch.dao.AbstractIndexTypeDao;
import org.duniter.elasticsearch.exception.InvalidFormatException;
import org.duniter.elasticsearch.user.PluginSettings;
import org.duniter.elasticsearch.user.model.UserProfile;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.xcontent.XContentBuilder;
......@@ -96,46 +98,51 @@ public class UserProfileDaoImpl extends AbstractIndexTypeDao<UserProfileDaoImpl>
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType())
.startObject("properties")
// version
.startObject(UserProfile.PROPERTY_VERSION)
.field("type", "integer")
.endObject()
// title
.startObject("title")
.startObject(UserProfile.PROPERTY_TITLE)
.field("type", "string")
.field("analyzer", stringAnalyzer)
.endObject()
// description
.startObject("description")
.startObject(UserProfile.PROPERTY_DESCRIPTION)
.field("type", "string")
.field("analyzer", stringAnalyzer)
.endObject()
// time
.startObject("time")
.startObject(UserProfile.PROPERTY_TIME)
.field("type", "integer")
.endObject()
// issuer
.startObject("issuer")
.startObject(UserProfile.PROPERTY_ISSUER)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
// city
.startObject("city")
.startObject(UserProfile.PROPERTY_CITY)
.field("type", "string")
.endObject()
// address
.startObject("address")
.startObject(UserProfile.PROPERTY_ADDRESS)
.field("type", "string")
.endObject()
// geoPoint
.startObject("geoPoint")
.startObject(Records.PROPERTY_GEO_POINT)
.field("type", "geo_point")
.endObject()
// avatar
.startObject("avatar")
.startObject(Records.PROPERTY_AVATAR)
.field("type", "attachment")
.startObject("fields") // fields
.startObject("content") // content
......@@ -155,7 +162,7 @@ public class UserProfileDaoImpl extends AbstractIndexTypeDao<UserProfileDaoImpl>
.endObject()
// social networks
.startObject("socials")
.startObject(Records.PROPERTY_SOCIALS)
.field("type", "nested")
.field("dynamic", "false")
.startObject("properties")
......@@ -171,7 +178,7 @@ public class UserProfileDaoImpl extends AbstractIndexTypeDao<UserProfileDaoImpl>
.endObject()
// tags
.startObject("tags")
.startObject(Records.PROPERTY_TAGS)
.field("type", "completion")
.field("search_analyzer", "simple")
.field("analyzer", "simple")
......
......@@ -92,13 +92,18 @@ public class UserSettingsDaoImpl extends AbstractIndexTypeDao<UserSettingsDaoImp
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject(getType())
.startObject("properties")
// version
.startObject(Record.PROPERTY_VERSION)
.field("type", "integer")
.endObject()
// time
.startObject("time")
.startObject(Record.PROPERTY_TIME)
.field("type", "integer")
.endObject()
// issuer
.startObject("issuer")
.startObject(Record.PROPERTY_ISSUER)
.field("type", "string")
.field("index", "not_analyzed")
.endObject()
......
......@@ -31,15 +31,18 @@ public class UserProfile extends Record {
public static final String PROPERTY_TITLE = "title";
public static final String PROPERTY_DESCRIPTION="description";
public static final String PROPERTY_CITY="city";
public static final String PROPERTY_EMAIL="email";
public static final String PROPERTY_LOCALE="locale";
public static final String PROPERTY_AVATAR="avatar";
public static final String PROPERTY_ADDRESS="address";
public static final String PROPERTY_CITY="city";
private String title;
private String description;
private String email;
private String locale;
private String address;
private String city;
public String getTitle() {
return title;
......@@ -72,4 +75,20 @@ public class UserProfile extends Record {
public void setLocale(String locale) {
this.locale = locale;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
}
Markdown is supported
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