Skip to content

Commit

Permalink
KAA-1146 Dao layer - modified Dtos
Browse files Browse the repository at this point in the history
  • Loading branch information
nocs00 committed Jul 7, 2016
1 parent 12bc4fa commit 5c788ac
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 72 deletions.
Expand Up @@ -32,7 +32,7 @@

@Entity
@Table(name = EVENT_SCHEMA_VERSION_TABLE_NAME)
public class EventSchemaVersion extends GenericModel<EventSchemaVersionDto> {
public class EventClassFamilyVersion extends GenericModel<EventSchemaVersionDto> {

private static final long serialVersionUID = -7490111487256831990L;

Expand All @@ -49,18 +49,18 @@ public class EventSchemaVersion extends GenericModel<EventSchemaVersionDto> {
@Column(name = EVENT_SCHEMA_VERSION_CREATED_TIME)
protected long createdTime;

public EventSchemaVersion() {
public EventClassFamilyVersion() {
}

public EventSchemaVersion(EventSchemaVersionDto dto) {
public EventClassFamilyVersion(EventSchemaVersionDto dto) {
this.id = getLongId(dto.getId());
this.schema = dto.getSchema();
this.version = dto.getVersion();
this.createdUsername = dto.getCreatedUsername();
this.createdTime = dto.getCreatedTime();
}

public EventSchemaVersion(Long id) {
public EventClassFamilyVersion(Long id) {
this.id = id;
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass()) {
return false;
}
EventSchemaVersion other = (EventSchemaVersion) obj;
EventClassFamilyVersion other = (EventClassFamilyVersion) obj;
if (createdTime != other.createdTime) {
return false;
}
Expand Down Expand Up @@ -155,7 +155,7 @@ protected EventSchemaVersionDto createDto() {

@Override
protected GenericModel<EventSchemaVersionDto> newInstance(Long id) {
return new EventSchemaVersion(id);
return new EventClassFamilyVersion(id);
}

@Override
Expand All @@ -171,7 +171,7 @@ public EventSchemaVersionDto toDto() {

@Override
public String toString() {
return "EventSchemaVersion [schema=" + schema + ", version=" + version + ", createdUsername=" + createdUsername + ", createdTime=" + createdTime
return "EventClassFamilyVersion [schema=" + schema + ", version=" + version + ", createdUsername=" + createdUsername + ", createdTime=" + createdTime
+ ", id=" + id + "]";
}
}
Expand Up @@ -18,30 +18,18 @@

import java.io.Serializable;

import org.kaaproject.kaa.common.dto.BaseSchemaDto;
import org.kaaproject.kaa.common.dto.HasId;

//TODO: Unique Key should be {tenantId, FQN, version}
public class EventClassDto implements HasId, Serializable {
public class EventClassDto extends BaseSchemaDto implements HasId, Serializable {

private static final long serialVersionUID = 2052580632293959408L;

private String id;
private String tenantId;
private String ecfId;
private String fqn;
private EventClassType type;
private String schema;
private int version;

@Override
public String getId() {
return id;
}

@Override
public void setId(String id) {
this.id = id;
}

public String getTenantId() {
return tenantId;
Expand Down Expand Up @@ -75,34 +63,18 @@ public void setType(EventClassType type) {
this.type = type;
}

public String getSchema() {
return schema;
}

public void setSchema(String schema) {
this.schema = schema;
}

public int getVersion() {
return version;
}

public void setVersion(int version) {
this.version = version;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((ecfId == null) ? 0 : ecfId.hashCode());
result = prime * result + ((fqn == null) ? 0 : fqn.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((schema == null) ? 0 : schema.hashCode());
result = prime * result
+ ((tenantId == null) ? 0 : tenantId.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + version;
result = prime * result + ((ctlSchemaId == null) ? 0 : ctlSchemaId.hashCode());
return result;
}

Expand Down Expand Up @@ -139,13 +111,6 @@ public boolean equals(Object obj) {
} else if (!id.equals(other.id)) {
return false;
}
if (schema == null) {
if (other.schema != null) {
return false;
}
} else if (!schema.equals(other.schema)) {
return false;
}
if (tenantId == null) {
if (other.tenantId != null) {
return false;
Expand All @@ -159,6 +124,10 @@ public boolean equals(Object obj) {
if (version != other.version) {
return false;
}
if (ctlSchemaId != other.ctlSchemaId) {
return false;
}

return true;
}

Expand All @@ -175,10 +144,10 @@ public String toString() {
builder.append(fqn);
builder.append(", type=");
builder.append(type);
builder.append(", schema=");
builder.append(schema);
builder.append(", version=");
builder.append(version);
builder.append(", ctlSchemaId=");
builder.append(ctlSchemaId);
builder.append("]");
return builder.toString();
}
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class EventClassFamilyDto implements HasId, Serializable {
private String description;
private String createdUsername;
private long createdTime;
private List<EventSchemaVersionDto> schemas;
private List<EventClassFamilyVersionDto> schemas;

@Override
public String getId() {
Expand Down Expand Up @@ -61,11 +61,11 @@ public void setName(String name) {
this.name = name;
}

public List<EventSchemaVersionDto> getSchemas() {
public List<EventClassFamilyVersionDto> getSchemas() {
return schemas;
}

public void setSchemas(List<EventSchemaVersionDto> schemas) {
public void setSchemas(List<EventClassFamilyVersionDto> schemas) {
this.schemas = schemas;
}

Expand Down
Expand Up @@ -17,20 +17,19 @@
package org.kaaproject.kaa.common.dto.event;

import java.io.Serializable;
import java.util.List;

import org.kaaproject.avro.ui.shared.RecordField;
import org.kaaproject.kaa.common.dto.HasId;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties({"schemaForm"})
public class EventSchemaVersionDto implements HasId, Serializable {
public class EventClassFamilyVersionDto implements HasId, Serializable {

private static final long serialVersionUID = -6565622945148633465L;

private String id;
private String schema;
protected RecordField schemaForm;
private List<EventClassDto> records;
private int version;
private String createdUsername;
private long createdTime;
Expand All @@ -45,20 +44,12 @@ public void setId(String id) {
this.id = id;
}

public String getSchema() {
return schema;
}

public void setSchema(String schema) {
this.schema = schema;
}

public RecordField getSchemaForm() {
return schemaForm;
public List<EventClassDto> getRecords() {
return records;
}

public void setSchemaForm(RecordField schemaForm) {
this.schemaForm = schemaForm;
public void setRecords(List<EventClassDto> records) {
this.records = records;
}

public int getVersion() {
Expand Down Expand Up @@ -92,8 +83,8 @@ public int hashCode() {
result = prime * result + (int) (createdTime ^ (createdTime >>> 32));
result = prime * result
+ ((createdUsername == null) ? 0 : createdUsername.hashCode());
result = prime * result + ((schema == null) ? 0 : schema.hashCode());
result = prime * result + version;
result = prime * result + ((records == null) ? 0 : records.hashCode());
return result;
}

Expand All @@ -108,7 +99,7 @@ public boolean equals(Object obj) {
if (getClass() != obj.getClass()) {
return false;
}
EventSchemaVersionDto other = (EventSchemaVersionDto) obj;
EventClassFamilyVersionDto other = (EventClassFamilyVersionDto) obj;
if (createdTime != other.createdTime) {
return false;
}
Expand All @@ -119,19 +110,19 @@ public boolean equals(Object obj) {
} else if (!createdUsername.equals(other.createdUsername)) {
return false;
}
if (schema == null) {
if (other.schema != null) {
if (records == null) {
if (other.records != null) {
return false;
}
} else if (!schema.equals(other.schema)) {
} else if (!records.equals(other.records)) {
return false;
}
return version == other.version;
}

@Override
public String toString() {
return "EventSchemaVersionDto [schema=" + schema + ", version="
return "EventClassFamilyVersionDto [version="
+ version + ", createdUsername=" + createdUsername
+ ", createdTime=" + createdTime + "]";
}
Expand Down

0 comments on commit 5c788ac

Please sign in to comment.