1 19 20 package org.apache.cayenne.project; 21 22 import java.io.File ; 23 24 import org.apache.cayenne.access.DataDomain; 25 import org.apache.cayenne.access.DataNode; 26 import org.apache.cayenne.conf.Configuration; 27 28 33 public class DataNodeConfigInfo { 34 protected String name; 35 protected String domain; 36 protected String adapter; 37 protected String dataSource; 38 protected File driverFile; 39 40 45 public DataNode findDataNode(Configuration config) 46 throws ProjectException { 47 DataDomain domainObj = null; 48 49 if (domain != null) { 51 domainObj = config.getDomain(domain); 52 53 if (domainObj == null) { 54 throw new ProjectException("Can't find domain named " + domain); 55 } 56 } else { 57 try { 58 domainObj = config.getDomain(); 59 } catch (Exception ex) { 60 throw new ProjectException("Project has no default domain.", ex); 61 } 62 63 if (domainObj == null) { 64 throw new ProjectException("Project has no domains configured."); 65 } 66 } 67 68 DataNode node = domainObj.getNode(name); 69 if (node == null) { 70 throw new ProjectException( 71 "Domain " 72 + domainObj.getName() 73 + " has no node named '" 74 + name 75 + "'."); 76 } 77 return node; 78 } 79 80 84 public String getAdapter() { 85 return adapter; 86 } 87 88 92 public String getDataSource() { 93 return dataSource; 94 } 95 96 100 public String getDomain() { 101 return domain; 102 } 103 104 108 public File getDriverFile() { 109 return driverFile; 110 } 111 112 116 public String getName() { 117 return name; 118 } 119 120 124 public void setAdapter(String adapter) { 125 this.adapter = adapter; 126 } 127 128 132 public void setDataSource(String dataSource) { 133 this.dataSource = dataSource; 134 } 135 136 140 public void setDomain(String domain) { 141 this.domain = domain; 142 } 143 144 148 public void setDriverFile(File driverFile) { 149 this.driverFile = driverFile; 150 } 151 152 156 public void setName(String name) { 157 this.name = name; 158 } 159 160 } 161 | Popular Tags |