public ESModelElementQuery modelelementQuery(
      ESPrimaryVersionSpec source,
      List<ESModelElementId> modelElements,
      int upper,
      int lower,
      boolean allVersions,
      boolean includeChangePackages) {

    // TODO: provide util method for mapping to internal classes
    List<ModelElementId> modelElementIds = new ArrayList<ModelElementId>();
    for (ESModelElementId id : modelElements) {
      modelElementIds.add(((ESModelElementIdImpl) id).getInternalAPIImpl());
    }

    PrimaryVersionSpec sourcePrimaryVersionSpec =
        ((ESPrimaryVersionSpecImpl) source).getInternalAPIImpl();

    ModelElementQuery modelelementQuery =
        HistoryQueryBuilder.modelelementQuery(
            sourcePrimaryVersionSpec,
            modelElementIds,
            upper,
            lower,
            allVersions,
            includeChangePackages);

    ESModelElementQueryImpl apiImpl = modelelementQuery.getAPIImpl();
    return apiImpl;
  }
 public ESModelElementQuery modelelementQuery(
     ESPrimaryVersionSpec source,
     ESModelElementId id,
     int upper,
     int lower,
     boolean allVersions,
     boolean includeCp) {
   ModelElementQuery modelelementQuery =
       HistoryQueryBuilder.modelelementQuery(
           ((ESPrimaryVersionSpecImpl) source).getInternalAPIImpl(),
           ((ESModelElementIdImpl) id).getInternalAPIImpl(),
           upper,
           lower,
           allVersions,
           includeCp);
   return modelelementQuery.getAPIImpl();
 }
 /**
  * Factory method for modelelements range queries.
  *
  * @param source source version
  * @param modelElements modelelements
  * @param upper upper limit
  * @param lower lower limit
  * @param allVersions include all versions, from all branches
  * @param includeCp include change packages
  * @return query
  */
 public static ModelElementQuery modelelementQuery(
     PrimaryVersionSpec source,
     List<ModelElementId> modelElements,
     int upper,
     int lower,
     boolean allVersions,
     boolean includeCp) {
   final ModelElementQuery query = VersioningFactory.eINSTANCE.createModelElementQuery();
   query.setSource(ModelUtil.clone(source));
   query.getModelElements().addAll(modelElements);
   query.setUpperLimit(upper);
   query.setLowerLimit(lower);
   query.setIncludeAllVersions(allVersions);
   query.setIncludeChangePackages(includeCp);
   query.setIncludeIncoming(false);
   query.setIncludeOutgoing(false);
   return query;
 }