Created
November 6, 2011 01:15
-
-
Save bikisuke/1342313 to your computer and use it in GitHub Desktop.
gexcelapiを使って、Excelからastah*のドメイン定義を作成するサンプル。(要astah* professionalライセンス)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.change_vision.jude.api.inf.project.* | |
import com.change_vision.jude.api.inf.model.* | |
import com.change_vision.jude.api.inf.editor.* | |
import org.jggug.kobo.gexcelapi.GExcel | |
class AstahGenerator { | |
static generate(data) { | |
def pa = ProjectAccessorFactory.getProjectAccessor() | |
def editor = ModelEditorFactory.getERModelEditor() | |
pa.create(‘output.asta’) | |
TransactionManager.beginTransaction() | |
def model = editor.createERModel(pa.getProject(), ‘ER’) | |
data.each { | |
def elements = pa.findElements(IERDatatype.class, it.type) | |
def type = elements? elements[0] : editor.createERDatatype(model, it.type) | |
editor.createERDomain(model, null, it.logicalName, null, type) | |
} | |
TransactionManager.endTransaction() | |
pa.save() | |
pa.close() | |
} | |
} | |
// excel読み込みはgexcelapiが便利です。 | |
def book = GExcel.open(‘demo.xls’) | |
def sheet = book[0] | |
def nameList = sheet.A_.findAll{it} | |
def typeList = sheet.C_.findAll{it} | |
def data = [] | |
for(i=0;i<nameList.size();i++) { | |
def params = [:] | |
params.logicalName = nameList[i] as String | |
params.type = typeList[i] as String | |
data << params | |
} | |
AstahGenerator.generate(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment