本文整理汇总了Java中com.odoo.core.orm.fields.OColumn.getRelationType方法的典型用法代码示例。如果您正苦于以下问题:Java OColumn.getRelationType方法的具体用法?Java OColumn.getRelationType怎么用?Java OColumn.getRelationType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.odoo.core.orm.fields.OColumn
的用法示例。
在下文中一共展示了OColumn.getRelationType方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateValues
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
private ContentValues[] generateValues(ContentValues values) {
OValues data_value = new OValues();
OValues rel_value = new OValues();
for (String key : values.keySet()) {
OColumn column = mModel.getColumn(key);
if (column != null) {
if (column.getRelationType() == null) {
data_value.put(key, values.get(key));
} else {
if (column.getRelationType() == OColumn.RelationType.ManyToOne) {
data_value.put(key, values.get(key));
} else {
rel_value.put(key, values.get(key).toString());
}
}
}
}
return new ContentValues[]{data_value.toContentValues(), rel_value.toContentValues()};
}
示例2: removeRelationColumns
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
private String[] removeRelationColumns(String[] projection) {
HashSet<String> columns = new HashSet<>();
if (projection != null && projection.length > 0 && mModel != null) {
for (String key : projection) {
OColumn column = mModel.getColumn(key);
if (column != null && column.getRelationType() == null) {
columns.add(key);
} else if (column != null && column.getRelationType() == OColumn.RelationType.ManyToOne) {
columns.add(key);
}
}
columns.addAll(Arrays.asList(new String[]{OColumn.ROW_ID, "id", "_is_active", "_write_date"}));
return columns.toArray(new String[columns.size()]);
}
return null;
}
示例3: getType
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
private String getType(OColumn column) {
try {
if (column.getRelationType() == null) {
if (column.getType().getSuperclass().isAssignableFrom(OTypeHelper.class)) {
OTypeHelper type = (OTypeHelper) column.getType().newInstance();
type.setSize(column.getSize());
return type.getType();
}
} else if (column.getRelationType() == OColumn.RelationType.ManyToOne) {
return new OInteger().getType();
}
} catch (Exception e) {
Log.e(TAG, e.getMessage());
e.printStackTrace();
}
return null;
}
示例4: createRelationTable
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
private void createRelationTable(OModel base_model, OColumn column) {
try {
OModel rel_model = base_model.createInstance(column.getType());
switch (column.getRelationType()) {
case ManyToOne:
case OneToMany:
createStatements(rel_model);
break;
case ManyToMany:
manyToManyTable(column, base_model);
// Creating master table for related column
createStatements(base_model.createInstance(column.getType()));
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: onCreate
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.base_mail_chatter_message_compose);
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
fileManager = new OFileManager(this);
Bundle extra = getIntent().getExtras();
mType = MessageType.valueOf(extra.getString("type"));
mModel = OModel.get(this, extra.getString("model"), null);
irAttachment = new IrAttachment(this);
mailMessage = new MailMessage(this);
server_id = extra.getInt("server_id");
if (mModel.getModelName().equals("res.partner")) {
partner_id = server_id;
} else {
ODataRow row = mModel.browse(mModel.selectRowId(server_id));
for (OColumn col : mModel.getColumns(false)) {
if (col.getType().isAssignableFrom(ResPartner.class)) {
if (col.getRelationType() != null
&& col.getRelationType() == OColumn.RelationType.ManyToOne) {
ODataRow partner = null;
if (!row.getString(col.getName()).equals("false")) {
partner = row.getM2ORecord(col.getName()).browse();
}
if (partner != null && partner.getInt("id") != 0) {
partner_id = partner.getInt("id");
}
}
}
}
}
findViewById(R.id.btnAttachment).setOnClickListener(this);
findViewById(R.id.btnSend).setOnClickListener(this);
findViewById(R.id.btnCancel).setOnClickListener(this);
edtSubject = (EditText) findViewById(R.id.messageSubject);
edtBody = (EditText) findViewById(R.id.messageBody);
horizontalScrollView = (LinearLayout) findViewById(R.id.attachmentsList);
init();
}
示例6: prepareFields
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
private void prepareFields() {
mColumns.clear();
mRelationColumns.clear();
List<Field> fields = new ArrayList<>();
fields.addAll(Arrays.asList(getClass().getSuperclass().getDeclaredFields()));
fields.addAll(Arrays.asList(getClass().getDeclaredFields()));
mDeclaredFields.clear();
for (Field field : fields) {
if (field.getType().isAssignableFrom(OColumn.class)) {
String name = field.getName();
try {
OColumn column = getColumn(field);
if (column != null) {
name = column.getName();
if (column.getRelationType() != null) {
mRelationColumns.add(column);
}
if (column.isFunctionalColumn()) {
if (column.canFunctionalStore()) {
mColumns.add(column);
}
mFunctionalColumns.add(column);
} else {
mColumns.add(column);
}
}
} catch (Exception e) {
e.printStackTrace();
}
mDeclaredFields.put(name, field);
}
}
}
示例7: projection
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
public String[] projection() {
List<String> names = new ArrayList<>();
for (OColumn column : getColumns()) {
if (column.getRelationType() == null || column.canFunctionalStore()) {
names.add(column.getName());
} else if (column.getRelationType() == OColumn.RelationType.ManyToOne) {
names.add(column.getName());
}
}
return names.toArray(new String[names.size()]);
}
示例8: getRelationColumns
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
private List<OColumn> getRelationColumns(String[] projection) {
List<OColumn> cols = new ArrayList<>();
if (projection != null) {
for (String key : projection) {
OColumn column = getColumn(key);
if (column.getRelationType() != null) {
cols.add(column);
}
}
} else {
cols.addAll(getRelationColumns());
}
return cols;
}
示例9: generateColumnStatement
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
private String generateColumnStatement(OModel model, List<OColumn> columns) {
StringBuffer column_statement = new StringBuffer();
List<String> finishedColumns = new ArrayList<>();
for (OColumn column : columns) {
if (!finishedColumns.contains(column.getName())) {
finishedColumns.add(column.getName());
String type = getType(column);
if (type != null) {
column_statement.append(column.getName());
column_statement.append(" " + type + " ");
if (column.isAutoIncrement()) {
column_statement.append(" PRIMARY KEY ");
column_statement.append(" AUTOINCREMENT ");
}
Object default_value = column.getDefaultValue();
if (default_value != null) {
column_statement.append(" DEFAULT ");
if (default_value instanceof String) {
column_statement.append("'" + default_value + "'");
} else {
column_statement.append(default_value);
}
}
column_statement.append(", ");
}
if (column.getRelationType() != null) {
createRelationTable(model, column);
}
}
}
return column_statement.toString();
}
示例10: createDropStatements
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
public void createDropStatements(OModel model) {
StringBuffer sql = null;
try {
if (!mModels.contains(model.getTableName())) {
mModels.add(model.getTableName());
sql = new StringBuffer();
sql.append("DROP TABLE IF EXISTS ");
sql.append(model.getTableName());
mSQLStatements.put(model.getTableName(), sql.toString());
Log.v(TAG, "Table Dropped : " + model.getTableName());
for (OColumn col : model.getColumns()) {
if (col.getRelationType() != null) {
switch (col.getRelationType()) {
case ManyToMany:
OModel rel = model.createInstance(col.getType());
String table_name = model.getTableName() + "_"
+ rel.getTableName() + "_rel";
sql = new StringBuffer();
sql.append("DROP TABLE IF EXISTS ");
sql.append(table_name);
mModels.add(table_name);
mSQLStatements.put(table_name, sql.toString());
Log.v(TAG, "Table Dropped : " + table_name);
break;
case ManyToOne:
case OneToMany:
createDropStatements(model.createInstance(col
.getType()));
break;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: onCreate
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.base_mail_chatter_message_compose);
getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
fileManager = new OFileManager(this);
Bundle extra = getIntent().getExtras();
mType = MessageType.valueOf(extra.getString("type"));
mModel = OModel.get(this, extra.getString("model"), null);
irAttachment = new IrAttachment(this, null);
mailMessage = new MailMessage(this, null);
server_id = extra.getInt("server_id");
if (mModel.getModelName().equals("res.partner")) {
partner_id = server_id;
} else {
ODataRow row = mModel.browse(mModel.selectRowId(server_id));
for (OColumn col : mModel.getColumns(false)) {
if (col.getType().isAssignableFrom(ResPartner.class)) {
if (col.getRelationType() != null
&& col.getRelationType() == OColumn.RelationType.ManyToOne) {
ODataRow partner = null;
if (!row.getString(col.getName()).equals("false")) {
partner = row.getM2ORecord(col.getName()).browse();
}
if (partner != null && partner.getInt("id") != 0) {
partner_id = partner.getInt("id");
}
}
}
}
}
findViewById(R.id.btnAttachment).setOnClickListener(this);
findViewById(R.id.btnSend).setOnClickListener(this);
findViewById(R.id.btnCancel).setOnClickListener(this);
edtSubject = (EditText) findViewById(R.id.messageSubject);
edtBody = (EditText) findViewById(R.id.messageBody);
horizontalScrollView = (LinearLayout) findViewById(R.id.attachmentsList);
init();
}
示例12: projection
import com.odoo.core.orm.fields.OColumn; //导入方法依赖的package包/类
public String[] projection(Boolean onlyServerColumns) {
List<String> names = new ArrayList<>();
for (OColumn column : getColumns(false)) {
if (column.getRelationType() == null || column.canFunctionalStore()) {
names.add(column.getName());
} else if (column.getRelationType() == OColumn.RelationType.ManyToOne) {
names.add(column.getName());
}
}
return names.toArray(new String[names.size()]);
}