本文整理汇总了Java中net.ssehub.easy.basics.modelManagement.ModelManagement类的典型用法代码示例。如果您正苦于以下问题:Java ModelManagement类的具体用法?Java ModelManagement怎么用?Java ModelManagement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModelManagement类属于net.ssehub.easy.basics.modelManagement包,在下文中一共展示了ModelManagement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: load
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Loads the main model.
* @param management Either {@link VarModel#INSTANCE} or {@link BuildModel#INSTANCE}
* @param fileEnding Either <tt>.ivml</tt> or <tt>_0.vil</tt>.
* @param <M> Either {@link Project} or {@link Script}.
* @return The loaded model or <tt>null</tt> if it was not found.
*/
private <M extends IModel> M load(ModelManagement<M> management, String fileEnding) {
M model = null;
File file = new File(tempModelsFolder, QmConstants.PROJECT_TOP_LEVEL + fileEnding);
URI vilURI = file.toURI();
ModelInfo<M> info = management.availableModels().getModelInfo(QmConstants.PROJECT_TOP_LEVEL, new Version(0),
vilURI);
if (null != info) {
try {
model = management.load(info);
} catch (ModelManagementException e) {
Bundle.getLogger(ModelModifier.class).exception(e);
}
}
return model;
}
示例2: loadPreferredModel
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Loads a model with the specified (model name, version) pair from the given {@link ModelManagement} instance.
* The model will only be loaded, if it can be loaded from the given <tt>locations</tt>
* (ordering of parameters will be considered).
*
* @param modelMgmt The {@link ModelManagement} instance from where the {@link IModel} should be loaded from, i.e.
* {@link net.ssehub.easy.varModel.management.VarModel#INSTANCE}
* or {@link net.ssehub.easy.instantiation.core.model.buildlangModel.BuildModel#INSTANCE}.
* @param modelDefinition A (model name, version) pair for specifying which {@link IModel} should be loaded.
* @param locations A ordered list of locations from where the {@link IModel} should be loaded from.
* @param <M> The specific model type, will be derived from the {@link ModelManagement} instance.
* Will be {@link net.ssehub.easy.varModel.model.Project}
* or {@link net.ssehub.easy.instantiation.core.model.buildlangModel.Script}.
* @return A loaded {@link IModel} or <tt>null</tt>.
*
* @throws ModelManagementException In case that the available information
* may become inconsistent due to this update
*/
static<M extends IModel> M loadPreferredModel(ModelManagement<M> modelMgmt,
IModelData modelDefinition, File... locations) throws ModelManagementException {
ModelInfo<M> result = null;
List<ModelInfo<M>> infos = modelMgmt.availableModels().getModelInfo(modelDefinition.getName(),
modelDefinition.getVersion());
if (null != infos && infos.size() > 0 && null != locations && locations.length > 0) {
for (int i = 0; i < locations.length && null == result; i++) {
File currentFile = locations[i];
URI currentURI = currentFile.toURI();
for (int j = 0; j < infos.size() && null == result; j++) {
ModelInfo<M> info = infos.get(j);
if (info.isContainedIn(currentURI)) {
result = info;
}
}
}
}
// Throws a ModelManagementException if result is null
return modelMgmt.load(result);
}
示例3: assertOutdated
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Asserts the outdated functionality on a model management instance.
*
* @param <R> model type
* @param mgt the management instance
* @param modelName the model name
* @throws ModelManagementException in case that model loading fails
*/
protected <R extends IModel> void assertOutdated(ModelManagement<R> mgt, String modelName)
throws ModelManagementException {
List<ModelInfo<R>> infos = mgt.availableModels().getModelInfo(modelName);
Assert.assertTrue("model not found", !infos.isEmpty());
R m0 = mgt.load(infos.get(0));
Assert.assertFalse("model is outdated", mgt.isOutdated(m0));
mgt.outdateAll();
Assert.assertTrue("model is not outdated", mgt.isOutdated(m0));
R m1 = mgt.load(infos.get(0));
Assert.assertFalse("model is outdated", mgt.isOutdated(infos.get(0)));
Assert.assertFalse("model is outdated", mgt.isOutdated(m1));
Assert.assertTrue("model instances shall not be equal after setting outdated", m0 != m1);
mgt.setOutdated(m1);
Assert.assertTrue("model is not outdated", mgt.isOutdated(m1));
R m2 = mgt.load(infos.get(0));
Assert.assertTrue("model instances shall not be equal after setting outdated", m1 != m2);
}
示例4: loadModel
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Loads the {@link Project} or the {@link Script} and adds it to the given {@link PersistentProject}.
* @param projectName The name of the {@link IModel} to load.
* @param projectVersion The {@link Version} of the {@link IModel} to load.
* @param modelType Must match to the given {@link IModel} type:
* <ul>
* <li>{@link Project} = {@link PathKind#IVML}</li>
* <li>{@link Script} = {@link PathKind#VIL}</li>
* </ul>
* @throws PersistenceException Will be thrown if an error occurred during
* the {@link ModelManagement#load(ModelInfo)} operation.
*/
@SuppressWarnings("unchecked")
public void loadModel(String projectName, String projectVersion, PathKind modelType)
throws PersistenceException {
switch(modelType) {
case IVML:
ProjectContainer projectContainer = (ProjectContainer) loadModel(projectName, projectVersion,
(ModelManagement<Model>) VarModel.INSTANCE, modelType);
project.setVarModel(projectContainer);
break;
case VIL:
ScriptContainer scriptContainer = (ScriptContainer) loadModel(projectName, projectVersion,
(ModelManagement<Model>) BuildModel.INSTANCE, modelType);
project.setScript(scriptContainer);
break;
default:
// Not needed
break;
}
}
示例5: addOrRemoveLocation
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Removed or adds a (temporary) folder for loading models from this locations.
* @param modelManagement {@link VarModel#INSTANCE}, {@link BuildModel#INSTANCE}, or {@link TemplateModel#INSTANCE}
* @param folder The folder to (un-)register
* @param add <tt>true</tt> the folder will be added as possible location for models, <tt>false</tt> the folder
* will be removed.
*/
private void addOrRemoveLocation(ModelManagement<? extends IModel> modelManagement, File folder, boolean add) {
try {
if (add) {
modelManagement.locations().addLocation(folder, ProgressObserver.NO_OBSERVER);
} else {
modelManagement.locations().removeLocation(folder, ProgressObserver.NO_OBSERVER);
}
} catch (ModelManagementException e) {
Bundle.getLogger(ModelModifier.class).exception(e);
}
}
示例6: addOrRemoveLocation
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Removed or adds a (temporary) folder for loading models from this locations.
* @param modelManagement {@link VarModel#INSTANCE}, {@link BuildModel#INSTANCE}, or {@link TemplateModel#INSTANCE}
* @param folder The folder to (un-)register
* @param add <tt>true</tt> the folder will be added as possible location for models, <tt>false</tt> the folder
* will be removed.
* @throws ModelManagementException If model files could not be parsed
*/
protected void addOrRemoveLocation(ModelManagement<? extends IModel> modelManagement, File folder, boolean add)
throws ModelManagementException {
if (add) {
modelManagement.locations().addLocation(folder, ProgressObserver.NO_OBSERVER);
} else {
modelManagement.locations().removeLocation(folder, ProgressObserver.NO_OBSERVER);
}
}
示例7: getProjectUri
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Returns the {@link URI} of the given
* {@link net.ssehub.easy.varModel.model.Project}.
*
* @param project
* the {@link net.ssehub.easy.varModel.model.Project} for which
* the {@link URI} should be returned
* @return the {@link URI} of the given project. May return
* <code>null</code> if the given project is <code>null</code> or
* the project URI could not be resolved.
*/
private java.net.URI getProjectUri(M project) {
java.net.URI varModelProjectUri = null;
if (project != null) {
ModelManagement<M> modelMgt = modelQuery.getModelManagement();
AvailableModels<M> availableModel = modelMgt.availableModels();
if (availableModel != null) {
ModelInfo<M> projectInfo = availableModel.getModelInfo(project);
if (projectInfo != null) {
varModelProjectUri = projectInfo.getLocation();
}
}
}
return varModelProjectUri;
}
示例8: ModelContainer
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
/**
* Constructor if an Exception occurred during parsing the model.
* The model can be used but not be saved, as long the semantic error is not solved.
* @param model The model, which should be managed by this container.
* @param description A description of an occurred semantic error while parsing the model.
* Can be <tt>null</tt>, then this constructor has the same behavior as {@link #ModelContainer(IModel)}.
* @param modelManager The container holding and managing all models of type <M>.
* @param location The location (folder) of the managed model.
*/
protected ModelContainer(M model, SemanticErrorDescription description, ModelManagement<M> modelManager,
Configuration location) {
this.model = model;
this.description = description;
this.modelManager = modelManager;
this.location = location;
modelManager.events().addModelListener(model, this);
}
示例9: getManagementInstance
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
@Override
protected ModelManagement<Script> getManagementInstance() {
return BuildModel.INSTANCE;
}
示例10: getModelManagement
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
@Override
public ModelManagement<Script> getModelManagement() {
return BuildModel.INSTANCE;
}
示例11: getModelManagement
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
@Override
public ModelManagement<Script> getModelManagement() {
return RtVilModel.INSTANCE;
}
示例12: getManagementInstance
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
@Override
protected ModelManagement<Script> getManagementInstance() {
return RtVilModel.INSTANCE;
}
示例13: getModelManagement
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
@Override
protected ModelManagement<Script> getModelManagement() {
return RtVilModel.INSTANCE;
}
示例14: getModelManagement
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
@Override
public ModelManagement<Template> getModelManagement() {
return TemplateModel.INSTANCE;
}
示例15: getModelManagement
import net.ssehub.easy.basics.modelManagement.ModelManagement; //导入依赖的package包/类
@Override
protected ModelManagement<Template> getModelManagement() {
return TemplateModel.INSTANCE;
}