blob: c7f7637fae8c8724a0b30b17ccbb2d683a4dbb17 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2006 IBM Corporation and others.
// 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:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.library.edit.util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.epf.uma.ContentElement;
import org.eclipse.epf.uma.Guidance;
import org.eclipse.epf.uma.MethodElement;
import org.eclipse.epf.uma.MethodPlugin;
import org.eclipse.epf.uma.util.AssociationHelper;
import org.eclipse.epf.uma.util.UmaUtil;
/**
* Class with static utility methods for querying method element
*
* @author Shilpa Toraskar
* @author Phong Nguyen Le
* @since 1.0
*/
public class MethodElementUtil {
/**
* Return method model of the object
*
* @param obj
* @return
*/
public static MethodPlugin getMethodModel(Object obj) {
return UmaUtil.getMethodPlugin((MethodElement) obj);
}
/**
* Returns list of models as specified.. 1. Method model of the object 2.
* Referenced models of the method model of the object (e.g. reference
* relationship)
*
* @param object
* @return
*/
public static List getAllModels(Object object) {
List allModels = new ArrayList();
// get method model of the object
MethodPlugin model = getMethodModel(object);
if (model != null) {
// get all base models
//
Misc.getAllBase(model, allModels);
allModels.add(model);
}
return allModels;
}
/**
* Returns references guidances for the given object
*
* @param object
* @return
*/
public static List getSelectedGuidances(EObject object) {
List itemList = new ArrayList();
List references = ((EObject) object).eCrossReferences();
if (references != null && references.size() > 0) {
for (Iterator it = references.iterator(); it.hasNext();) {
Object obj = (Object) it.next();
if (obj instanceof Guidance) {
itemList.add(obj);
}
}
}
itemList
.addAll(AssociationHelper.getPractices((ContentElement) object));
return itemList;
}
}