1 23 package org.objectweb.medor.query.jorm.lib; 24 25 import org.objectweb.jorm.api.PMapper; 26 import org.objectweb.medor.api.MedorException; 27 import org.objectweb.medor.api.TupleStructure; 28 import org.objectweb.medor.datasource.api.DataStore; 29 import org.objectweb.medor.lib.BasicTupleStructure; 30 import org.objectweb.medor.query.api.OrderField; 31 import org.objectweb.medor.query.api.QueryLeaf; 32 import org.objectweb.medor.query.jorm.api.JormExtent; 33 import org.objectweb.medor.query.jorm.api.JormField; 34 35 import java.util.Iterator ; 36 import java.util.Map ; 37 38 44 public abstract class BasicJormExtent 45 extends BasicTupleStructure 46 implements JormExtent, QueryLeaf, TupleStructure { 47 50 protected String name; 51 52 55 protected String pnFieldName; 56 57 protected PNameField identifier = null; 58 59 62 protected DataStore myStore; 63 64 67 protected PMapper mapper; 68 69 protected String projectName = null; 70 71 74 protected boolean includeSubclasses = false; 75 76 public BasicJormExtent() { 77 } 78 79 public BasicJormExtent(String _name, String pnFieldName) { 80 this.name = (_name == null ? "" : _name); 81 this.pnFieldName = pnFieldName; 82 } 83 84 public Object clone(Object clone, 85 Map obj2clone) throws CloneNotSupportedException { 86 clone = super.clone(clone, obj2clone); 87 BasicJormExtent bje = (BasicJormExtent) clone; 88 bje.name = name; 89 bje.pnFieldName = pnFieldName; 90 bje.identifier = (PNameField) getClone(identifier, obj2clone); 91 bje.myStore = myStore; 92 bje.mapper = mapper; 93 bje.projectName = projectName; 94 bje.includeSubclasses = includeSubclasses; 95 return clone; 96 } 97 98 public Iterator iterateFields() { 99 return fields.iterator(); 100 } 101 102 public String getFieldName(String nodeName, String fieldName) { 103 if (nodeName == null || nodeName.length() == 0) 104 return fieldName; 105 else 106 return nodeName + "." + fieldName; 107 } 108 109 112 public PMapper getPMapper() { 113 return mapper; 114 } 115 116 public void setPMapper(PMapper m, String projectName) { 117 mapper = m; 118 this.projectName = projectName; 119 } 120 121 public String getProjectName() { 122 return projectName; 123 } 124 125 public void setProjectName(String projectName) { 126 this.projectName = projectName; 127 } 128 129 public void setDataStore(DataStore ds) { 130 myStore = ds; 131 } 132 133 public String getPNameFieldName() { 134 return getFieldName(name, pnFieldName); 135 } 136 137 public abstract String getJormName(); 138 139 public JormField getIdentifierField() { 140 return identifier; 141 } 142 143 public boolean withSubClasses() { 144 return includeSubclasses; 145 } 146 147 public void setWithSubClasses(boolean incSubClasses) { 148 includeSubclasses = incSubClasses; 149 } 150 151 154 public String getName() { 155 return this.name; 156 } 157 158 161 public TupleStructure getTupleStructure() { 162 return this; 163 } 164 165 168 public DataStore getDataStore() { 169 return myStore; 170 } 171 172 public void setDistinct(boolean d) throws MedorException { 173 throw new MedorException("Cannot set distinct on a JORM Leaf"); 174 } 175 176 public boolean getDistinct() { 177 return false; 178 } 179 180 public void setOrderBy(OrderField[] orderfields) throws MedorException { 181 throw new MedorException("Order by not supported on JormExtent"); 182 } 183 184 public OrderField[] getOrderBy() { 185 return null; 186 } 187 188 } 189 | Popular Tags |