BrightSide Workbench Full Report + Source Code
AbstractDirectEntityCtrl.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2020 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.elephant.direct;
20 
21 import org.turro.string.Strings;
22 import org.turro.action.IEntityCtrl;
23 import org.turro.elephant.context.IConstructor;
24 import org.turro.entities.Entities;
25 import org.turro.entities.IElephantEntity;
26 import org.turro.marker.ElephantMarker;
27 
32 public abstract class AbstractDirectEntityCtrl extends AbstractDirectContentCtrl implements IEntityCtrl {
33 
34  private final String entityAttribute;
35  protected String entityPath;
36  protected IElephantEntity iee;
38 
39  public AbstractDirectEntityCtrl(String tmplRoot, String entityAttribute) {
40  super(tmplRoot);
41  this.entityAttribute = entityAttribute;
42  }
43 
44  @Override
45  protected ElephantMarker getMarker(IConstructor constructor) {
46  ElephantMarker marker = super.getMarker(constructor);
47  if(!Strings.isBlank(entityPath)) {
48  marker.put("entityPath", entityPath);
49  marker.put("iee", iee);
50  marker.put(entityAttribute, iee.getEntity());
51  }
52  return marker;
53  }
54 
55  /* IEntityCtrl */
56 
57  @Override
58  public void setConstructor(IConstructor constructor) {
59  norReentrantConstructor = constructor;
60  }
61 
62  @Override
63  public void setEntityPath(String entityPath) {
64  this.entityPath = entityPath;
66  }
67 
68  @Override
69  public boolean hasContent() {
70  return iee != null && iee.getEntity() != null;
71  }
72 
73 }
ElephantMarker getMarker(IConstructor constructor)
AbstractDirectEntityCtrl(String tmplRoot, String entityAttribute)
static IElephantEntity getController(String path)
Definition: Entities.java:78
Object put(Object key, Object value)