2012-06-17 20:34:50 +02:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2012 IT Just working.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IT Just working - initial API and implementation
|
|
|
|
*******************************************************************************/
|
2015-01-03 16:34:32 +01:00
|
|
|
package com.minres.scviewer.database.text
|
2012-06-17 19:53:05 +02:00
|
|
|
|
2015-01-03 16:34:32 +01:00
|
|
|
import com.minres.scviewer.database.AssociationType;
|
|
|
|
import com.minres.scviewer.database.DataType
|
2015-01-06 17:14:16 +01:00
|
|
|
import com.minres.scviewer.database.ITxAttributeType
|
|
|
|
import com.minres.scviewer.database.ITxAttribute
|
2012-06-17 19:53:05 +02:00
|
|
|
|
2015-01-06 17:14:16 +01:00
|
|
|
class TxAttributeTypeFactory {
|
|
|
|
private static final instance = new TxAttributeTypeFactory()
|
2012-06-17 19:53:05 +02:00
|
|
|
|
|
|
|
def attributes = [:]
|
|
|
|
|
2015-01-06 17:14:16 +01:00
|
|
|
private TxAttributeTypeFactory() {
|
|
|
|
TxAttributeTypeFactory.metaClass.constructor = {-> instance }
|
2012-06-17 19:53:05 +02:00
|
|
|
}
|
|
|
|
|
2015-01-06 17:14:16 +01:00
|
|
|
ITxAttributeType getAttrType(String name, DataType dataType, AssociationType type){
|
2015-01-03 16:34:32 +01:00
|
|
|
def key = name+":"+dataType.toString()
|
2015-01-06 17:14:16 +01:00
|
|
|
ITxAttributeType res
|
2012-06-17 19:53:05 +02:00
|
|
|
if(attributes.containsKey(key)){
|
|
|
|
res=attributes[key]
|
|
|
|
} else {
|
2015-01-06 17:14:16 +01:00
|
|
|
res=new TxAttributeType(name, dataType, type)
|
2012-06-17 19:53:05 +02:00
|
|
|
attributes[key]=res
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
}
|