public code v1
This commit is contained in:
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
*
|
||||
*/
|
||||
package flintstones.entity.domain;
|
||||
|
||||
import flintstones.entity.common.interfaces.IdentifiedEntity;
|
||||
import flintstones.entity.common.interfaces.TypedEntity;
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
import flintstones.helper.data.wxml.WNode;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
|
||||
/**
|
||||
* The Domain Class.
|
||||
*/
|
||||
public abstract class Domain implements Cloneable, Comparable<Domain>, IdentifiedEntity, TypedEntity {
|
||||
|
||||
/** The domain name. */
|
||||
private String name = null; // Must be null
|
||||
|
||||
/** The Constant EXTENSION_POINT. */
|
||||
public static final String EXTENSION_POINT = "flintstones.entity.domain"; //$NON-NLS-1$
|
||||
public static final String EXTENSION_POINT_CATEGORY="flintstones.entity.domain.domain_category";
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public static enum Fields implements ExtensionEnum {
|
||||
/** The Domain. */
|
||||
Domain,
|
||||
/** The id. */
|
||||
uid,
|
||||
/** The name. */
|
||||
name,
|
||||
/** The type. */
|
||||
category,
|
||||
|
||||
label,
|
||||
|
||||
/** The implementation. */
|
||||
implementation,
|
||||
/** The type. */
|
||||
type // is now label?
|
||||
};
|
||||
|
||||
/**
|
||||
* Instantiates a new domain.
|
||||
*/
|
||||
public Domain() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the new name
|
||||
*/
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Midpoint.
|
||||
*
|
||||
* @return the midpoint
|
||||
*/
|
||||
public abstract double midpoint();
|
||||
|
||||
/**
|
||||
* Format description domain.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public abstract String formatDescriptionDomain();
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final HashCodeBuilder hcb = new HashCodeBuilder(17, 31);
|
||||
hcb.append(this.name);
|
||||
hcb.append(this.type);
|
||||
return hcb.toHashCode();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (obj.getClass() != this.getClass())
|
||||
return false;
|
||||
|
||||
final Domain other = (Domain) obj;
|
||||
|
||||
final EqualsBuilder eb = new EqualsBuilder();
|
||||
eb.append(this.name, other.name);
|
||||
eb.append(this.type, other.type);
|
||||
|
||||
return eb.isEquals();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#clone()
|
||||
*/
|
||||
@Override
|
||||
public Object clone() {
|
||||
Domain result = null;
|
||||
|
||||
try {
|
||||
result = (Domain) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Domain domain) {
|
||||
|
||||
if (this.name == null)
|
||||
return -1;
|
||||
|
||||
return this.name.compareTo(domain.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Write.
|
||||
*
|
||||
* @param writer the writer
|
||||
* @throws XMLStreamException the XML stream exception
|
||||
*/
|
||||
public abstract void write(XMLStreamWriter writer) throws XMLStreamException;
|
||||
|
||||
/**
|
||||
* Read.
|
||||
*
|
||||
* @param node the node
|
||||
*/
|
||||
public abstract void read(WNode node);
|
||||
|
||||
|
||||
/* IdentifiedEntity implementation */
|
||||
private String serviceId = null;
|
||||
|
||||
@Override
|
||||
public final String getId() {
|
||||
return serviceId;
|
||||
};
|
||||
|
||||
@Override
|
||||
public final void updateId() {
|
||||
serviceId = calculateId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String calculateId() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
|
||||
/* TypedEntity implementation */
|
||||
private String type;
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package flintstones.entity.domain;
|
||||
|
||||
public abstract class DomainInstance {
|
||||
|
||||
private String type;
|
||||
private String label;
|
||||
private Domain domain;
|
||||
|
||||
public String getType() {return type; }
|
||||
|
||||
public void setType(String type) {this.type = type;}
|
||||
|
||||
public String getLabel() {return label; }
|
||||
|
||||
public void setLabel(String label) {this.label = label;}
|
||||
|
||||
public void setCleanDomain(Domain d) {domain = d;}
|
||||
|
||||
protected Domain getDomain() { return domain;}
|
||||
|
||||
public abstract Domain getInstance();
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package flintstones.entity.domain;
|
||||
|
||||
public class DomainInstanceMockup extends DomainMockup {
|
||||
|
||||
private String fastId;
|
||||
|
||||
public DomainInstanceMockup(String category) {
|
||||
super(category);
|
||||
}
|
||||
|
||||
public DomainInstanceMockup(String fastId, String id, String label, String category) {
|
||||
super(id, label, category);
|
||||
this.fastId = fastId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImage() {
|
||||
if(id == null)
|
||||
return domains.get(0).getImage();
|
||||
|
||||
return "domain/" + id + ".png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCategory() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getFastId() {return fastId; }
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package flintstones.entity.domain;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class DomainMockup {
|
||||
|
||||
protected String id;
|
||||
protected String label;
|
||||
protected String category;
|
||||
|
||||
ArrayList<DomainMockup> domains = new ArrayList<>();
|
||||
|
||||
public DomainMockup(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public void addDomain(DomainMockup domain) {
|
||||
domains.add(domain);
|
||||
}
|
||||
|
||||
public DomainMockup[] getChildren() {
|
||||
|
||||
if(label != null || id != null)
|
||||
return new DomainMockup[0];
|
||||
|
||||
return domains.toArray(new DomainMockup[0]);
|
||||
}
|
||||
|
||||
public DomainMockup(String id, String label, String category) {
|
||||
this.id = id;
|
||||
this.label = label;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return id != null ? label : category;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
|
||||
public String getImage() {
|
||||
if(id == null)
|
||||
return domains.get(0).getImage();
|
||||
|
||||
return "domain/" + id + ".png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String template = "[{0}] {1} {2}";
|
||||
return MessageFormat.format(template, category, label, id);
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.entity.domain.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String Domain_entity;
|
||||
public String Domain_entities;
|
||||
public String Domain_count;
|
||||
public String Domain_type_entities;
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Domain_entity=Domain
|
||||
Domain_entities=Domains
|
||||
Domain_count=The number of domains
|
||||
Domain_type_entities=The domains of type
|
||||
Domain_type=The type of domain
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
Domain_entity=Dominio
|
||||
Domain_entities=Dominios
|
||||
Domain_count=El número de dominios
|
||||
Domain_type_entities=Los dominios de tipo
|
||||
Domain_type=El tipo de dominio
|
||||
Reference in New Issue
Block a user