1 56 package org.objectstyle.cayenne.project; 57 58 import java.io.File ; 59 60 import org.objectstyle.cayenne.access.DataDomain; 61 import org.objectstyle.cayenne.access.DataNode; 62 import org.objectstyle.cayenne.conf.Configuration; 63 64 69 public class DataNodeConfigInfo { 70 protected String name; 71 protected String domain; 72 protected String adapter; 73 protected String dataSource; 74 protected File driverFile; 75 76 81 public DataNode findDataNode(Configuration config) 82 throws ProjectException { 83 DataDomain domainObj = null; 84 85 if (domain != null) { 87 domainObj = config.getDomain(domain); 88 89 if (domainObj == null) { 90 throw new ProjectException("Can't find domain named " + domain); 91 } 92 } else { 93 try { 94 domainObj = config.getDomain(); 95 } catch (Exception ex) { 96 throw new ProjectException("Project has no default domain.", ex); 97 } 98 99 if (domainObj == null) { 100 throw new ProjectException("Project has no domains configured."); 101 } 102 } 103 104 DataNode node = domainObj.getNode(name); 105 if (node == null) { 106 throw new ProjectException( 107 "Domain " 108 + domainObj.getName() 109 + " has no node named '" 110 + name 111 + "'."); 112 } 113 return node; 114 } 115 116 120 public String getAdapter() { 121 return adapter; 122 } 123 124 128 public String getDataSource() { 129 return dataSource; 130 } 131 132 136 public String getDomain() { 137 return domain; 138 } 139 140 144 public File getDriverFile() { 145 return driverFile; 146 } 147 148 152 public String getName() { 153 return name; 154 } 155 156 160 public void setAdapter(String adapter) { 161 this.adapter = adapter; 162 } 163 164 168 public void setDataSource(String dataSource) { 169 this.dataSource = dataSource; 170 } 171 172 176 public void setDomain(String domain) { 177 this.domain = domain; 178 } 179 180 184 public void setDriverFile(File driverFile) { 185 this.driverFile = driverFile; 186 } 187 188 192 public void setName(String name) { 193 this.name = name; 194 } 195 196 } 197 | Popular Tags |