19 package org.turro.entities;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.HashMap;
24 import java.util.HashSet;
26 import org.turro.string.Strings;
27 import org.turro.annotation.ElephantEntity;
28 import org.turro.collections.KeyValueMap;
29 import org.turro.path.Path;
30 import org.turro.plugin.contacts.IContact;
31 import org.turro.reflection.Instances;
44 if(!Strings.isBlank(path)) {
45 Path entityPath = Path.pathFrom(path);
51 Object obj = iElEntity.getObject(entityPath);
79 if(!Strings.isBlank(path)) {
91 if(entity instanceof String) {
93 }
else if(entity instanceof Path) {
95 }
else if(entity !=
null) {
106 public static Collection<Object>
getEntities(String search,
int maxResults) {
110 public static Collection<Object>
getEntities(String root, String search,
int maxResults) {
111 return getEntities(root, search, maxResults,
null);
114 public static Collection<Object>
getEntities(String search,
int maxResults, KeyValueMap kvm) {
115 if(kvm ==
null) { kvm =
new KeyValueMap(
new HashMap()); }
116 ArrayList<Object> list =
new ArrayList<>();
117 if(!Strings.isBlank(search)) {
119 list.addAll(iElEntity.getEntitites(search, maxResults, kvm));
125 public static Collection<Object>
getEntities(String root, String search,
int maxResults, KeyValueMap kvm) {
126 if(kvm ==
null) { kvm =
new KeyValueMap(
new HashMap()); }
127 ArrayList<Object> list =
new ArrayList<>();
128 if(!Strings.isBlank(search)) {
130 for(String entityRoot : Strings.csvToList(root)) {
131 list.addAll(iElEntity.getEntitites(entityRoot, search, maxResults, kvm));
142 if(!list.isEmpty()) {
143 return list.stream().findFirst().get();
149 ArrayList<Object> list =
new ArrayList<>();
151 list.addAll(iElEntity.getRelatedByRole(role, contact));
158 .stream().map((iElEntity) -> iElEntity.hasRelatedRole(role, contact)).anyMatch((has) -> (has));
164 HashSet<String>
set =
new HashSet<>();
165 for(Object entity : entitites) {
167 if(!Strings.isBlank(path)) {
175 HashSet<String>
set =
new HashSet<>();
176 for(Object entity : entitites) {
178 if(!Strings.isBlank(path)) {
186 HashSet<String>
set =
new HashSet<>();
188 if(!Strings.isBlank(path)) {
195 HashSet<String>
set =
new HashSet<>();
197 set.addAll(iElEntity.getAllowedRoots());
static Set< String > getEntityPaths(Object entity)
static IElephantEntity getController(Object entity)
static IElephantEntity getController(String path)
static IElephantEntity emptyController()
static Object getSingleRelatedByRole(EntityRole role, IContact contact)
static Collection< Object > getEntities(String search, int maxResults)
static boolean hasRelatedRole(EntityRole role, IContact contact)
static Collection< Object > getEntities(String root, String search, int maxResults, KeyValueMap kvm)
static Collection< Object > getEntities(String search, int maxResults, KeyValueMap kvm)
static Set< String > getEntityPaths(Object[] entitites)
static Collection< Object > getRelatedByRole(EntityRole role, IContact contact)
static Set< String > getEntityPaths(Collection entitites)
static Set< String > getAllowedRoots()
static Object getObject(String path)
static Collection< Object > getEntities(String root, String search, int maxResults)
static IElephantEntity getMainEntity(Object entity)
IElephantEntity getController(String entityPath)
IElephantEntity getMain(Object entity)