hudson.model.Item.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中hudson.model.Item.getParent()方法的一些代码示例,展示了Item.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Item.getParent()方法的具体详情如下:
包路径:hudson.model.Item
类名称:Item
方法名:getParent

Item.getParent介绍

[英]Gets the parent that contains this item.
[中]获取包含此项的父项。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@GuardedBy("lock")
private boolean _contains(@Nonnull Item item) {
  if (registrations.isEmpty()) {
    // no point walking everything if there is nothing in-flight
    return false;
  }
  while (item != null) {
    if (registrations.contains(item)) {
      return true;
    }
    if (item.getParent() instanceof Item) {
      item = (Item) item.getParent();
    } else {
      break;
    }
  }
  return false;
}

代码示例来源:origin: jenkinsci/jenkins

public final <T extends Item> T getItem(String pathName, Item context, Class<T> type) {
  return getItem(pathName,context!=null?context.getParent():null,type);
}

代码示例来源:origin: jenkinsci/jenkins

public final Item getItem(String pathName, Item context) {
  return getItem(pathName,context!=null?context.getParent():null);
}

代码示例来源:origin: jenkinsci/jenkins

@Override
/**
 * Called after the user has clicked OK in the New Job page when 
 * Copy existing job has been selected.
 * The fields in item will be displayed in when the config page is loaded
 * displayed.
 */
public void onCopied(Item src, Item item) {
  // bug 5056825 - Display name field should be cleared when you copy a job within the same folder.
  if(item instanceof AbstractItem && src.getParent() == item.getParent()) {
    AbstractItem dest = (AbstractItem)item;
    try {                
      dest.setDisplayName(null);
    } catch(IOException ioe) {
      LOGGER.log(Level.WARNING, String.format("onCopied():Exception while trying to clear the displayName for Item.name:%s", item.getName()), ioe);
    }
  }
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Auto-completes possible job names.
 *
 * @param type
 *      Limit the auto-completion to the subtype of this type.
 * @param value
 *      The value the user has typed in. Matched as a prefix.
 * @param self
 *      The contextual item for which the auto-completion is provided to.
 *      For example, if you are configuring a job, this is the job being configured.
 * @param container
 *      The nearby contextual {@link ItemGroup} to resolve relative job names from.
 * @since 1.489
 */
public static <T extends Item> AutoCompletionCandidates ofJobNames(final Class<T> type, final String value, @CheckForNull Item self, ItemGroup container) {
  if (self==container)
    container = self.getParent();
  return ofJobNames(type, value, container);
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Short for {@code getRelativeNameFrom(item.getParent())}
 *
 * @return String like "../foo/bar".
 *      {@code null} if one of item parents is not an {@link Item}.
 * @since 1.419
 */
@Nullable
default String getRelativeNameFrom(@Nonnull Item item)  {
  return getRelativeNameFrom(item.getParent());
}

代码示例来源:origin: jenkinsci/gitlab-plugin

private StringBuilder retrieveParentUrl(Item item) {
  if (item.getParent() instanceof Item) {
    Item parent = (Item) item.getParent();
    return retrieveParentUrl(parent).append('/').append(Util.rawEncode(parent.getName()));
  } else {
    return new StringBuilder();
  }
}

代码示例来源:origin: jenkinsci/jenkins

parents.put(g, depth++);
if (g instanceof Item)
  g = ((Item)g).getParent();
else
  g = null;
if (buf.length()>0) buf.insert(0,separationString);
buf.insert(0,useDisplayName ? i.getDisplayName() : i.getName());
ItemGroup gr = i.getParent();

代码示例来源:origin: jenkinsci/jenkins

/**
 * Returns true if {@link BuildPtr} points to the given job
 * or one of its subordinates.
 *
 * <p>
 * This is useful to check if an artifact in MavenModule
 * belongs to MavenModuleSet. 
 */
public boolean belongsTo(Job job) {
  Item p = Jenkins.getInstance().getItemByFullName(name);
  while(p!=null) {
    if(p==job)
      return true;
    // go up the chain while we
    ItemGroup<? extends Item> parent = p.getParent();
    if (!(parent instanceof Item)) {
      return false;
    }
    p = (Item) parent;
  }
  return false;
}

代码示例来源:origin: jenkinsci/jenkins

private static SuggestedItem build(SearchableModelObject searchContext, Item top) {
  ItemGroup<? extends Item> parent = top.getParent();
  if (parent instanceof Item) {
    Item parentItem = (Item)parent;
    return new SuggestedItem(build(searchContext, parentItem), top);
  }
  return new SuggestedItem(top);
}

代码示例来源:origin: jenkinsci/jenkins

if (s.equals("..")) {
  if (ctx instanceof Item) {
    ctx = ((Item)ctx).getParent();
    continue;

代码示例来源:origin: jenkinsci/jenkins

String prefix = rootItem.getParent().getFullName();
if (!prefix.isEmpty()) {
  prefix += '/';

代码示例来源:origin: jenkinsci/jenkins

ItemGroup<?> current = itemBySystemUser.getParent();
do {
  if (current instanceof Item) {
    final Item i = (Item) current;
    current = i.getParent();
    if (!i.hasPermission(userAuth, Item.READ)) {
      canDiscoverTheItem = false;

代码示例来源:origin: jenkinsci/jenkins

break;
if (item.getParent() instanceof Item) {
  item = (Item) item.getParent();
} else {
  break;
        break;
      if (item.getParent() instanceof Item) {
        item = (Item) item.getParent();
      } else {
        break;

代码示例来源:origin: jenkinsci/jenkins

container = ((Item)container).getParent();
new Visitor(p).onItemGroup(container);

代码示例来源:origin: jenkinsci/jenkins

String url = "";
while(true) {
  ItemGroup ig = i.getParent();
  url = i.getShortUrl()+url;

代码示例来源:origin: org.jenkins-ci.plugins/cloudbees-folder

private static void invalidateBuildHealthReports(Item item) {
  while (item != null) {
    if (item instanceof AbstractFolder) {
      ((AbstractFolder) item).invalidateBuildHealthReports();
    }
    if (item.getParent() instanceof Item) {
      item = (Item) item.getParent();
    } else {
      break;
    }
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/cloudbees-folder

public HandlingMode applicability(Item item) {
  if (item instanceof TopLevelItem
      && item instanceof AbstractItem
      && item.getParent() instanceof DirectlyModifiableTopLevelItemGroup
      && hasValidDestination(item)) {
    return HandlingMode.HANDLE;
  } else {
    return HandlingMode.SKIP;
  }
}

代码示例来源:origin: org.jenkins-ci.plugins/cloudbees-folder

@Override public HttpResponse handle(Item item, ItemGroup<?> destination, AtomicReference<Item> newItem, List<? extends RelocationHandler> chain) throws IOException, InterruptedException {
  if (!(destination instanceof DirectlyModifiableTopLevelItemGroup)) {
    return chain.isEmpty() ? null : chain.get(0).handle(item, destination, newItem, chain.subList(1, chain.size()));
  }
  Item result = doMove(item, (DirectlyModifiableTopLevelItemGroup) destination);
  newItem.set(result);
  // AbstractItem.getUrl does weird magic here which winds up making it redirect to the old location, so inline the correct part of this method.
  return HttpResponses.redirectViaContextPath(result.getParent().getUrl() + result.getShortUrl());
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

private static SuggestedItem build(SearchableModelObject searchContext, Item top) {
  ItemGroup<? extends Item> parent = top.getParent();
  if (parent instanceof Item) {
    Item parentItem = (Item)parent;
    return new SuggestedItem(build(searchContext, parentItem), top);
  }
  return new SuggestedItem(top);
}

相关文章