All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tinygroup.database.config.view.View Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
/**
 *  Copyright (c) 1997-2013, www.tinygroup.org ([email protected]).
 *
 *  Licensed under the GPL, Version 3.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.gnu.org/licenses/gpl.html
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.tinygroup.database.config.view;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import org.tinygroup.metadata.config.BaseObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @author chenjiao
 * 
 */
@XStreamAlias("view")
public class View extends BaseObject {
	@XStreamAsAttribute
	private String schema;
	@XStreamAlias("view-fields")
	List fieldList;
	@XStreamAlias("view-conditions")
	List conditionList;// 表间有主外键关系的,不用加条件
	@XStreamAlias("order-by-fields")
	List orderByFieldList;
	@XStreamAlias("view-tables")
	List tableList;
	@XStreamAlias("view-havings")
	List havingList;// 表间有主外键关系的,不用加条件

	public String getName() {
		if (getSchema() == null || "".equals(getSchema())) {
			return super.getName();
		}
		return String.format("%s.%s", getSchema(), super.getName());
	}

	public String getSchema() {
		return schema;
	}

	public void setSchema(String schema) {
		this.schema = schema;
	}

	public List getHavingList() {
		if (havingList == null) {
			havingList = new ArrayList();
		}
		return havingList;
	}

	public void setHavingList(List havingList) {
		this.havingList = havingList;
	}

	public List getTableList() {
		if (tableList == null) {
			tableList = new ArrayList();
		}
		return tableList;
	}

	public void setTableList(List tableList) {
		this.tableList = tableList;
	}

	public List getFieldList() {
		if (fieldList == null) {
			fieldList = new ArrayList();
		}
		return fieldList;
	}

	public void setFieldList(List fieldList) {
		this.fieldList = fieldList;
	}

	public List getConditionList() {
		if (conditionList == null) {
			conditionList = new ArrayList();
		}
		return conditionList;
	}

	public void setConditionList(List conditionList) {
		this.conditionList = conditionList;
	}

	public List getOrderByFieldList() {
		if (orderByFieldList == null) {
			orderByFieldList = new ArrayList();
		}
		return orderByFieldList;
	}

	public void setOrderByFieldList(List orderByFieldList) {
		this.orderByFieldList = orderByFieldList;
	}

	@XStreamAlias("group-by-fields")
	private List groupByFieldList;

	public List getGroupByFieldList() {
		if (groupByFieldList == null) {
			groupByFieldList = new ArrayList();
		}
		return groupByFieldList;
	}

	public void setGroupByFieldList(List groupByFieldList) {
		this.groupByFieldList = groupByFieldList;
	}
	
	public ViewField getViewField(String tableFieldId){
		for (ViewField viewField : fieldList) {
			if(viewField.getTableFieldId().equals(tableFieldId)){
				return viewField;
			}
			
		}
		return null;
	}
	
	public ViewTable getViewTable(String viewTableId){
		for (ViewTable viewTable : tableList) {
			if(viewTable.getId().equals(viewTableId)){
				return viewTable;
			}
		}
		return null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy