mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
No effective change - code cleanup - remove unused
This commit is contained in:
@@ -1,57 +0,0 @@
|
||||
package com.avaje.ebeaninternal.server.deploy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.avaje.ebeaninternal.server.deploy.id.ImportedId;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Build a map of logical to physical names for use in Orm Updates.
|
||||
*
|
||||
*/
|
||||
public class DeployUpdateMapFactory {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DeployUpdateMapFactory.class);
|
||||
|
||||
/**
|
||||
* Build a map of logical to physical names for use in Orm Updates for a given descriptor.
|
||||
* <p>
|
||||
* This includes the dbWrite scalar properties and imported foreign key properties.
|
||||
* </p>
|
||||
*/
|
||||
public static Map<String,String> build(BeanDescriptor<?> descriptor) {
|
||||
|
||||
Map<String,String> deployMap = new HashMap<String,String>();
|
||||
|
||||
String shortName = descriptor.getName();
|
||||
String beanName = shortName.toLowerCase();
|
||||
deployMap.put(beanName, descriptor.getBaseTable());
|
||||
|
||||
BeanProperty[] baseScalar = descriptor.propertiesBaseScalar();
|
||||
for (BeanProperty baseProp : baseScalar) {
|
||||
// excluding formula, secondary table properties
|
||||
if (baseProp.isDbInsertable() || baseProp.isDbUpdatable()){
|
||||
deployMap.put(baseProp.getName().toLowerCase(), baseProp.getDbColumn());
|
||||
}
|
||||
}
|
||||
|
||||
BeanPropertyAssocOne<?>[] oneImported = descriptor.propertiesOneImported();
|
||||
for (BeanPropertyAssocOne<?> assocOne : oneImported) {
|
||||
|
||||
ImportedId importedId = assocOne.getImportedId();
|
||||
if (importedId == null){
|
||||
String m = descriptor.getFullName()+" importedId is null for associated: "+assocOne.getFullBeanName();
|
||||
logger.error(m);
|
||||
|
||||
} else if (importedId.isScalar()){
|
||||
deployMap.put(importedId.getLogicalName(), importedId.getDbColumn());
|
||||
}
|
||||
}
|
||||
|
||||
return deployMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -98,37 +98,6 @@ public class DeployTableJoinColumn {
|
||||
return localDbColumn + " = " + foreignDbColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if either the local or foreign column is null.
|
||||
* <p>
|
||||
* Both columns need to be defined. If one is null then typically it is
|
||||
* derived as the primary key column.
|
||||
* </p>
|
||||
*/
|
||||
public boolean hasNullColumn() {
|
||||
return localDbColumn == null || foreignDbColumn == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* When only ONE column has been set by deployment information return that one.
|
||||
* <p>
|
||||
* Used with hasNullColumn() to set the foreignDbColumn for OneToMany joins.
|
||||
* </p>
|
||||
*/
|
||||
public String getNonNullColumn() {
|
||||
if (localDbColumn == null && foreignDbColumn == null) {
|
||||
throw new IllegalStateException("expecting only one null column?");
|
||||
|
||||
} else if (localDbColumn != null && foreignDbColumn != null) {
|
||||
throw new IllegalStateException("expecting one null column?");
|
||||
}
|
||||
if (localDbColumn != null) {
|
||||
return localDbColumn;
|
||||
} else {
|
||||
return foreignDbColumn;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this column should be insertable.
|
||||
*/
|
||||
@@ -150,17 +119,6 @@ public class DeployTableJoinColumn {
|
||||
return foreignDbColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the foreign database column name.
|
||||
* <p>
|
||||
* Used when this is derived from Primary Key and not set explicitly in the
|
||||
* deployment information.
|
||||
* </p>
|
||||
*/
|
||||
public void setForeignDbColumn(String foreignDbColumn) {
|
||||
this.foreignDbColumn = foreignDbColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the local database column name.
|
||||
*/
|
||||
@@ -168,11 +126,4 @@ public class DeployTableJoinColumn {
|
||||
return localDbColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the local database column name.
|
||||
*/
|
||||
public void setLocalDbColumn(String localDbColumn) {
|
||||
this.localDbColumn = localDbColumn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user