本文整理汇总了Java中gov.nih.nci.ncicb.xmiinout.domain.UMLModel类的典型用法代码示例。如果您正苦于以下问题:Java UMLModel类的具体用法?Java UMLModel怎么用?Java UMLModel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UMLModel类属于gov.nih.nci.ncicb.xmiinout.domain包,在下文中一共展示了UMLModel类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findInheritedAttributeDefinition
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
public static UMLAttribute findInheritedAttributeDefinition(UMLModel model, AttributeMetadata attributeMeta, UMLClass holdingObject)
{
UMLClass superClass=holdingObject;
while (superClass !=null){
UMLClass preSuperClass=superClass;
superClass=null;
for (UMLGeneralization clazzG : preSuperClass.getGeneralizations()) {
UMLClass gClass =(UMLClass) clazzG.getSupertype();
if (gClass != preSuperClass) {
for(UMLAttribute att : gClass.getAttributes())
{
if (att.getName().equals(attributeMeta.getName()))
return att;
}
superClass=gClass;
}
}
}
return null;
}
示例2: getAllClassesInModel
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
private List<UMLClass> getAllClassesInModel(UMLModel model) {
List<UMLClass> classes = new LinkedList<UMLClass>();
List<UMLPackage> packages = new ArrayList<UMLPackage>();
packages.addAll(model.getPackages());
for (int i = 0; i < packages.size(); i++) {
UMLPackage pack = packages.get(i);
packages.addAll(pack.getPackages());
classes.addAll(pack.getClasses());
}
return classes;
}
示例3: generateMapping
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
/**
* Generate HBM mapping given the UML object/data model
* @param model The Object/Data model created with Enterprise Architecture following caCORE SDK convention
* @param outDir The root directory of output files
* @throws GenerationException
*/
public void generateMapping(UMLModel model, String outDir) throws GenerationException
{
HibernateMappingTransformer transformer=(HibernateMappingTransformer)ObjectFactory.getObject("HibernateMappingTransformer");
Properties umlProp=(Properties)ObjectFactory.getObject("UMLModelFileProperties");
Log.logInfo(this,"Generate Hibernate mapping... Include Package... default setting:"+ umlProp.getProperty("Include Package"));
//found the root package name of the "Logical Model"
UMLPackage logicalPck=model.getPackage("Logical View").getPackage("Logical Model");
Collection <UMLPackage> modelPcks=logicalPck.getPackages();
String rootPckName=umlProp.getProperty("Include Package");
for (UMLPackage onePck :modelPcks)
{
String pckName=onePck.getName();
if (!(pckName==null||pckName.equals("")||pckName.equals("java")||pckName.equals("Diagrams")))
rootPckName=rootPckName+","+pckName;
}
if (!rootPckName.equals(""))
umlProp.setProperty("Include Package", rootPckName);
Log.logInfo(this,"Generate Hibernate mapping... included package:"+ umlProp.getProperty("Include Package"));
//set output directory
FileHandler fileHandler=(FileHandler)ObjectFactory.getObject("HibernateMappingFilehandler");
Log.logInfo(this,"Generate Hibernate mapping... Output Directory... default setting:"+ fileHandler.getOutputDir());
if (outDir!=null&&!outDir.equals(""))
fileHandler.setOutputDir(outDir);
Log.logInfo(this,"Generate Hibernate mapping... Output Directory:"+fileHandler.getOutputDir());
transformer.execute(model);
}
示例4: main
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) throws Exception {
/**
//initialize code generator
String fileName = (args!=null && args.length >0) ? args[0] : "CodegenConfig.xml";
ObjectFactory.initialize(fileName);
//manipulate fileHandler
FileHandler fileHandler=(FileHandler)ObjectFactory.getObject("HibernateMappingFilehandler");
fileHandler.setOutputDir("new_output");
System.out.println("CodegenTest.main()..output dir:"+fileHandler.getOutputDir());
//manipulate umlProp
// Properties umlProp=(Properties)ObjectFactory.getObject("UMLModelFileProperties");
// Enumeration umlKeys=umlProp.propertyNames();//.keys();
// umlProp.setProperty("Include Package", "com");
//
// while(umlKeys.hasMoreElements())
// {
// String propKey=(String)umlKeys.nextElement();
// String propValue=(String)umlProp.getProperty(propKey);
// System.out.println("CodegenTest.main()..UML property:"+propKey +"="+propValue);
// }
//
HibernateMappingTransformer transformer=(HibernateMappingTransformer)ObjectFactory.getObject("HibernateMappingTransformer");
// String xmiFilePath="C:\\myProject\\caCORE40Src\\models\\sdk.xmi";
XmiModelMetadata xmlModelMeta=new XmiModelMetadata(xmiFilePath);
UMLModel model=xmlModelMeta.getHandler().getModel();
generator.generateMapping(model);
transformer.execute(model);
**/
HBMGenerateCacoreIntegrator generator= HBMGenerateCacoreIntegrator.getInstance();
String xmiFilePath="C:\\caAdapter\\caAdapter4.0\\binDownload\\workingspace\\Object_to_DB_Example\\sdk.xmi";
XmiModelMetadata xmlModelMeta=new XmiModelMetadata(xmiFilePath);
UMLModel model=xmlModelMeta.getHandler().getModel();
generator.generateMapping(model,"generatorOut");
}
示例5: loadUMLModel
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
private TreeSet loadUMLModel(UMLModel model)
{
TreeSet rtnSet=new TreeSet(new XPathComparator());
XmiTraversalPath xmiPath=new XmiTraversalPath(model.getName());
// System.out.println("XmiModelMetadata.loadUMLModel()..path Nevigator:"+xmiPath.pathNevigator());
umlHashMap.put(xmiPath.pathNevigator(), model);
for( UMLPackage pkg : model.getPackages() )
{
loadPackage(rtnSet,xmiPath, pkg);
}
return rtnSet;
}
示例6: deAnnotateAssociationMapping
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
/**
* Delete the implements-association and correlation-table annotation tags for an association mapping
* <ul>
* <li> always delete association mapping tag:implements-association
* <li> delete correlation-table tag if the association is uni-directional
* <li> delete correlation-table tag if the association is uni-directional and the other end is not mapped
*</ul>
* @param umlModel The target UML model
* @param sourcePath The full path of an Object in the Logical Model
* @param targetPath The full path of a table in the Data Model
* @return <ul>
* <li>true if the association mapping is successfully created.
* <li>false if he association mapping exist or failed with other reason
*/
public static boolean deAnnotateAssociationMapping(UMLModel umlModel, String sourcePath, String targetPath)
{
//remove "mapped-attributes" tag from UMLModel
UMLAttribute xpathAttr=ModelUtil.findAttribute(umlModel,targetPath);
xpathAttr.removeTaggedValue("implements-association");
ModelMetadata modelMeta=CumulativeMappingGenerator.getInstance().getMetaModel();
MetaObject metaObj=(MetaObject)modelMeta.getModelMetadata().get(sourcePath);
if (metaObj instanceof AttributeMetadata)
{
UMLAttribute umlAttribute=ModelUtil.findAttribute(umlModel, sourcePath);
if (umlAttribute.getTaggedValue("correlation-table")!=null)
return (removeTagValue(umlAttribute, "correlation-table")&&removeTagValue(umlAttribute, "mapped-collection-table"));
else
return removeTagValue(umlAttribute, "mapped-collection-table");
}
AssociationMetadata asscMeta=(AssociationMetadata)metaObj;//modelMeta.getModelMetadata().get(sourcePath);
if (asscMeta==null)
return false;
//remove "inverse-of" for many-to-on
if (asscMeta.getMultiplicity()==1&&asscMeta.getReciprocalMultiplity()==-1)
{
xpathAttr.removeTaggedValue("inverse-of");
}
UMLAssociation umlAssc=asscMeta.getUMLAssociation();
//check if the association is uni-directional
UMLAssociationEnd endOne=(UMLAssociationEnd)umlAssc.getAssociationEnds().get(0);
UMLAssociationEnd endTwo=(UMLAssociationEnd)umlAssc.getAssociationEnds().get(1);
if (endOne.getRoleName()==null|endOne.getRoleName().equals("")
|endTwo.getRoleName()==null|endTwo.getRoleName().equals(""))
return removeTagValue(umlAssc, "correlation-table");
UMLAssociationEndBean otherEnd=(UMLAssociationEndBean)endOne;
UMLAssociationEndBean thisEnd=(UMLAssociationEndBean)endTwo;
if (endTwo.getRoleName().equals(asscMeta.getRoleName()))
{
otherEnd=(UMLAssociationEndBean)endTwo;
thisEnd=(UMLAssociationEndBean)endOne;
}
String otherEndFullPath= ModelUtil.getFullName((UMLClass)otherEnd.getUMLElement())+"."+thisEnd.getRoleName();
ColumnMetadata targetColumn=(ColumnMetadata)modelMeta.getModelMetadata().get(targetPath);
if (targetColumn==null)
return false;
UMLClass targetTbl=ModelUtil.findClass(umlModel, targetColumn.getParentXPath());
if (targetTbl==null)
return false;
Log.logInfo(targetColumn, "XMIAnnotationUtil.deAnnotateAssociationMapping()..the other end:"+otherEndFullPath);
String otherEndClearPath=getCleanPath(modelMeta.getMmsPrefixObjectModel(), otherEndFullPath);
for(UMLAttribute tblColumnAttr:targetTbl.getAttributes())
{
UMLTaggedValue oneAttrAsscTag=tblColumnAttr.getTaggedValue("implements-association");
if (oneAttrAsscTag!=null &&oneAttrAsscTag.getValue().equalsIgnoreCase(otherEndClearPath))
{
Log.logInfo(oneAttrAsscTag, "The other end is mapped:"+otherEndClearPath+"..."+tblColumnAttr.getName());
return false;
}
}
//the association end is the only mapped end, remove the correlation tag
return removeTagValue(umlAssc, "correlation-table");
}
示例7: annotateAssociationMapping
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
/**
* Add/update the implements-association and correlation-table annotation tags for an association mapping
* <ul>
* <li> always add association mapping tag:implements-association
* <li> determine if a correlation-table is used.
* <ul>
* <li>A correlation-table can not work as the data source of any object
* <li>Add a correlation-table tag when the first end of an association is mapped
* <li>Update/delete the correlation-table tag when the second association end is mapped
* <li>All the correlation-table tag should be cleared once the table is assigned as data source of an object
* </ul>
* <li> add correlation-table tag if not exist and required:correlation-table
* <li> update correlation-table tag if exist and required:correlation-table
*</ul>
* @param umlModel The target UML model
* @param sourcePath The full path of an Object in the Logical Model
* @param targetPath The full path of a table in the Data Model
* @return <ul>
* <li>true if the association mapping is successfully created.
* <li>false if he association mapping exist or failed with other reason
*/
public static boolean annotateAssociationMapping(UMLModel umlModel, String sourcePath, String targetPath)
{
UMLAttribute tblColumn=ModelUtil.findAttribute(umlModel, targetPath);
ModelMetadata modelMeta=CumulativeMappingGenerator.getInstance().getMetaModel();
//remove the leading string:"Logical View.Logical Model." from source path
String pureSrcPath=XMIAnnotationUtil.getCleanPath(modelMeta.getMmsPrefixObjectModel(), sourcePath);
XMIAnnotationUtil.addTagValue(tblColumn, "implements-association", pureSrcPath);
LinkedHashMap modelMetaHash =modelMeta.getModelMetadata();
//add inverse of tag if "many-to-one"
MetaObject metaEndObj=(MetaObject)modelMetaHash.get(sourcePath);
if (metaEndObj instanceof AssociationMetadata)
{
AssociationMetadata asscEndMeta=(AssociationMetadata)metaEndObj;
if (asscEndMeta.getMultiplicity()==1&&asscEndMeta.getReciprocalMultiplity()==-1)
{
XMIAnnotationUtil.addTagValue(tblColumn, "inverse-of", pureSrcPath);
}
}
ColumnMetadata columnMeta =(ColumnMetadata)modelMetaHash.get(targetPath);
if (columnMeta==null)
return false;
String tblPath=columnMeta.getTableMetadata().getXPath();
UMLClass tblClass=ModelUtil.findClass(umlModel, tblPath);
//check if table is the data source of any object
//to determine if it is a correlation-table
for(UMLDependency existDep:tblClass.getDependencies())
{
if (existDep.getStereotype()==null)
Log.logInfo(existDep, "...Dependency stereotype is NULL...target table:"+((UMLClass)existDep.getClient()).getName()+" is the datasource of object:"+((UMLClass)existDep.getSupplier()).getName());
else if (existDep.getStereotype().equalsIgnoreCase("DataSource"))
{
Log.logInfo(existDep, "Target can not be a correlation table...DataSource link exist...target table:"+((UMLClass)existDep.getClient()).getName()+" is the datasource of object:"+((UMLClass)existDep.getSupplier()).getName());
return false;
}
}
//check the association end in the Logical Model
MetaObject metaObj=(MetaObject)modelMetaHash.get(sourcePath);
if (metaObj instanceof AssociationMetadata)
{
AssociationMetadata asscMeta=(AssociationMetadata)modelMetaHash.get(sourcePath);
UMLAssociation umlAssc=asscMeta.getUMLAssociation();
addTagValue(umlAssc,"correlation-table",tblClass.getName());
}
else if (metaObj instanceof AttributeMetadata)
{
UMLAttribute umlAttribute=ModelUtil.findAttribute(umlModel, sourcePath);
addTagValue(umlAttribute,"mapped-collection-table",tblClass.getName());
}
return true;
}
示例8: cvsToXmiGeneration
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
public ValidatorResults cvsToXmiGeneration(String mappingFile) throws Exception
{
File file = new File(mappingFile);
//init() - read parameters from mappingFile
MapParserImpl parser = new MapParserImpl();
ValidatorResults validatorResults = parser.parse(file.getParent(), new FileReader(file));
if (validatorResults != null && validatorResults.hasFatal())
{//immediately return if it has fatal errors.
return validatorResults;
}
Mapping mapping = parser.getMapping();//returnResult.getMapping();
String xmiFile = mapping.getTargetComponent().getFile().getAbsolutePath();
System.out.println("CsvToXmiMappingPanel.cvsToXmiGeneration()..mapping target xmi file:"+xmiFile);
XmiInOutHandler handler=getXmiModelMeta().getHandler();
UMLModel model=handler.getModel();
//clear out the xmi file so duplicate tagvalues are not added on multiple saves
for( UMLPackage pkg : model.getPackages() )
{
clearXMLNamespacePackages( pkg );
}
//for each map in mapList to the following
for (gov.nih.nci.caadapter.hl7.map.Map map : mapping.getMaps() )
{
UMLAttribute column = null;
column = ModelUtil.findAttribute( model, map.getTargetMapElement().getDataXmlPath());//.getXPath());//.getXmlPath() );
System.out.println("Annotate Attribute :"+map.getTargetMapElement().getDataXmlPath() +"..."+map.getTargetMapElement().getXmlPath() + "XMLNamespace.. "+ map.getSourceMapElement().getXmlPath());
if ( column != null ) {
System.out.println("Annotate Attribute :"+map.getTargetMapElement().getXmlPath() + "XMLNamespace.. "+ map.getSourceMapElement().getXmlPath());
column.addTaggedValue( "XMLNamespace", map.getSourceMapElement().getXmlPath() );
}
}
//write xmi file
handler.save(xmiFile);
setSaveFile(file);
//redraw mapping panel
middlePanel.getMappingDataManager().setMappingData(mapping);
return validatorResults;
}
示例9: getModel
import gov.nih.nci.ncicb.xmiinout.domain.UMLModel; //导入依赖的package包/类
/**
* @return Returns the model.
*/
public UMLModel getModel() {
return handler.getModel();
}