19 package org.turro.alliance.db.entities;
21 import java.io.Serializable;
23 import javax.json.JsonValue;
24 import javax.persistence.Entity;
25 import javax.persistence.Id;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.Transient;
28 import org.turro.string.Strings;
29 import org.turro.alliance.db.AlliancePU;
30 import org.turro.elephant.db.IdUtils;
31 import org.turro.jpa.entity.IDaoEntity;
32 import org.turro.json.IJSONizable;
33 import org.turro.math.Zero;
34 import org.turro.path.UniquePath;
35 import org.turro.util.Chars;
44 @Id
private Long categoryId;
48 private String uniquePath;
51 private String pathName;
61 this.categoryId = categoryId;
77 this.uniquePath = uniquePath;
89 if(pathName ==
null) {
91 StringBuilder sb =
new StringBuilder(
getName());
92 while(current !=
null) {
93 sb.insert(0, Chars.forward().spaced().toString())
97 pathName = sb.toString();
103 this.pathName = pathName;
115 return Strings.isBlank(name);
124 uniquePath = UniquePath.getPath(
this, c -> Long.toString(c.getCategoryId()), c -> c.getParent());
125 if(Strings.isBlank(uniquePath)) parent =
null;
137 public String
toJson(Map<String, Object> properties) {
138 return toJson(
this, properties);
static AxCategory fromJson(JsonValue value)
void setName(String name)
void setUniquePath(String uniquePath)
void setCategoryId(Long categoryId)
void setPathName(String pathName)
void setParent(AxCategory parent)
String toJson(Map< String, Object > properties)
static long getNewLongIdFromLong(Dao dao, String table, String field)
static boolean orNull(Number value)
default void prepareSave()