Parses the packages sheet

@param repo {@link Repository} for the packages
@param intermediateResults {@link IntermediateParseResults} containing the parsed tag entities
324810
private void parsePackagesSheet(
      Repository<Entity> repo, IntermediateParseResults intermediateResults) {
    if (repo == null) return;

    // Collect packages
    int rowIndex = 1;
    for (Entity packageEntity : resolvePackages(repo)) {
      rowIndex++;
      parseSinglePackage(intermediateResults, rowIndex, packageEntity);
    }
  }
603763
public static Option repositories(final String... repositoryUrls) {
        validateNotEmptyContent(repositoryUrls, true, "Repository URLs");
        final List<RepositoryOption> options = new ArrayList<RepositoryOption>();
        for (String repositoryUrl : repositoryUrls) {
            options.add(repository(repositoryUrl));
        }
        return repositories(options.toArray(new RepositoryOption[options.size()]));
    }
995189
@SuppressWarnings("deprecation")
    public /*abstract*/ void parseAssociatedNames(Item item, Collection<GitHubRepositoryName> result) {
        if (Util.isOverridden(
                GitHubRepositoryNameContributor.class,
                getClass(),
                "parseAssociatedNames",
                Job.class,
                Collection.class
        )) {
            // if this impl is legacy, it cannot contribute to non-jobs, so not an error
            if (item instanceof Job) {
                parseAssociatedNames((Job<?, ?>) item, result);
            }
        } else  if (Util.isOverridden(
                GitHubRepositoryNameContributor.class,
                getClass(),
                "parseAssociatedNames",
                AbstractProject.class,
                Collection.class
        )) {
            // if this impl is legacy, it cannot contribute to non-projects, so not an error
            if (item instanceof AbstractProject) {
                parseAssociatedNames((AbstractProject<?, ?>) item, result);
            }
        } else {
            throw new AbstractMethodError("you must override the new overload of parseAssociatedNames");
        }
    }
95650
public void load(RulesDefinition.NewRepository repo) {
    for (RulesDefinition.NewRule rule : repo.rules()) {
      String name = i18n.getName(repo.key(), rule.key());
      if (StringUtils.isNotBlank(name)) {
        rule.setName(name);
      }

      String desc = i18n.getDescription(repo.key(), rule.key());
      if (StringUtils.isNotBlank(desc)) {
        rule.setHtmlDescription(desc);
      }

      for (RulesDefinition.NewParam param : rule.params()) {
        String paramDesc = i18n.getParamDescription(repo.key(), rule.key(), param.key());
        if (StringUtils.isNotBlank(paramDesc)) {
          param.setDescription(paramDesc);
        }
      }
    }
  }
1257317
private static PersistenceUnitMetadata parsePersistenceUnit(final URL url, final String[] persistenceUnits,
            Element top, final String versionName)
    {
        PersistenceUnitMetadata metadata = new PersistenceUnitMetadata(versionName, getPersistenceRootUrl(url), url);

        String puName = top.getAttribute("name");

        if (!Arrays.asList(persistenceUnits).contains(puName))
        {
            // Returning null because this persistence unit is not intended for
            // creating entity manager factory.
            return null;
        }

        if (!isEmpty(puName))
        {
            log.trace("Persistent Unit name from persistence.xml: " + puName);
            metadata.setPersistenceUnitName(puName);
            String transactionType = top.getAttribute("transaction-type");
            if (StringUtils.isEmpty(transactionType)
                    || PersistenceUnitTransactionType.RESOURCE_LOCAL.name().equals(transactionType))
            {
                metadata.setTransactionType(PersistenceUnitTransactionType.RESOURCE_LOCAL);
            }
            else if (PersistenceUnitTransactionType.JTA.name().equals(transactionType))
            {
                metadata.setTransactionType(PersistenceUnitTransactionType.JTA);
            }
        }

        NodeList children = top.getChildNodes();
        for (int i = 0; i < children.getLength(); i++)
        {
            if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
            {
                Element element = (Element) children.item(i);
                String tag = element.getTagName();

                if (tag.equals("provider"))
                {
                    metadata.setProvider(getElementContent(element));
                }
                else if (tag.equals("properties"))
                {
                    NodeList props = element.getChildNodes();
                    for (int j = 0; j < props.getLength(); j++)
                    {
                        if (props.item(j).getNodeType() == Node.ELEMENT_NODE)
                        {
                            Element propElement = (Element) props.item(j);
                            // if element is not "property" then skip
                            if (!"property".equals(propElement.getTagName()))
                            {
                                continue;
                            }

                            String propName = propElement.getAttribute("name").trim();
                            String propValue = propElement.getAttribute("value").trim();
                            if (isEmpty(propValue))
                            {
                                propValue = getElementContent(propElement, "");
                            }
                            metadata.getProperties().put(propName, propValue);
                        }
                    }
                }
                else if (tag.equals("class"))
                {
                    metadata.getClasses().add(getElementContent(element));
                }
                else if (tag.equals("jar-file"))
                {
                    metadata.addJarFile(getElementContent(element));
                }
                else if (tag.equals("exclude-unlisted-classes"))
                {
                    String excludeUnlisted = getElementContent(element);
                    metadata.setExcludeUnlistedClasses(Boolean.parseBoolean(excludeUnlisted));
                }
            }
        }
        PersistenceUnitTransactionType transactionType = getTransactionType(top.getAttribute("transaction-type"));
        if (transactionType != null)
        {
            metadata.setTransactionType(transactionType);
        }

        return metadata;
    }
203689
func parseRepositoryTag(repos string) (string, string) {
	n := strings.LastIndex(repos, ":")
	if n < 0 {
		return repos, ""
	}
	if tag := repos[n+1:]; !strings.Contains(tag, "/") {
		return repos[:n], tag
	}
	return repos, ""
}
678370
public static RepositoryPackage fromPackageRepository(File input) throws IOException, ParseException {
		PackageRepository repo = new PackageRepository(input);
		return repo.getPackage();
	}
1328309
@Override
    @SuppressWarnings({"PMD.NPathComplexity", "PMD.ExcessiveMethodLength", "PMD.NcssMethodCount"}) // agreed, fixme
    public List<GitRequest> getPulls(GitHubRepo repo, String status, boolean firstRun, Map<Long, String> prMap) throws MalformedURLException, HygieiaException {

        List<GitRequest> pulls = new ArrayList<>();
        String decryptedPassword = decryptString(repo.getPassword(), settings.getKey());
        GitHubParsed gitHubParsed = new GitHubParsed((String) repo.getOptions().get("url"));
        String branch = (repo.getBranch() != null) ? repo.getBranch() : "master";
        String personalAccessToken = (String) repo.getOptions().get("personalAccessToken");
        String decryptedPersonalAccessToken = decryptString(personalAccessToken, settings.getKey());

        String pageUrl = gitHubParsed.getApiUrl().concat("/pulls?state=" + status + "&base=" + branch + "&sort=updated&direction=desc");

        boolean lastPage = false;
        boolean stop = false;
        String queryUrlPage = pageUrl;

        while (!lastPage && !stop) {
            LOG.info("Executing [" + queryUrlPage);
            ResponseEntity<String> response = makeRestCall(queryUrlPage, repo.getUserId(), decryptedPassword,decryptedPersonalAccessToken);
            JSONArray jsonArray = parseAsArray(response);
            for (Object item : jsonArray) {
                JSONObject jsonObject = (JSONObject) item;
                String message = str(jsonObject, "title");
                String number = str(jsonObject, "number");
                LOG.info("pr " + number + " " + message);
                String sha = str(jsonObject, "merge_commit_sha");

                JSONObject userObject = (JSONObject) jsonObject.get("user");
                String name = str(userObject, "login");
                String created = str(jsonObject, "created_at");
                String merged = str(jsonObject, "merged_at");
                String closed = str(jsonObject, "closed_at");
                String  updated = str(jsonObject, "updated_at");
                long createdTimestamp = new DateTime(created).getMillis();
                String commentsUrl = str(jsonObject, "comments_url");
                String commitStatusesUrl = str(jsonObject, "statuses_url");
                String reviewCommentsUrl = str(jsonObject, "review_comments_url");
                String reviewsUrl = str(jsonObject, "url") + "/reviews";

                GitRequest pull = new GitRequest();

                if (merged != null && merged.length() >= 10) {
                    long mergedTimestamp = new DateTime(merged).getMillis();
                    pull.setScmCommitTimestamp(mergedTimestamp);
                    pull.setResolutiontime((mergedTimestamp - createdTimestamp) / (24 * 3600000));
                }
                pull.setUserId(name);
                pull.setScmUrl(repo.getRepoUrl());
                pull.setScmBranch(branch);
                pull.setTimestamp(createdTimestamp);
                pull.setScmRevisionNumber(sha);
                pull.setScmCommitLog(message);
                pull.setCreatedAt(createdTimestamp);
                pull.setClosedAt(new DateTime(closed).getMillis());
                pull.setMergedAt(new DateTime(merged).getMillis());
                pull.setUpdatedAt(new DateTime(updated).getMillis());
                pull.setNumber(number);
                pull.setRequestType("pull");
                pull.setState("open");
                if (merged != null) {
                    pull.setState("merged");
                } else if (closed != null) {
                    pull.setState("closed");
                }
                pull.setOrgName(gitHubParsed.getOrgName());
                pull.setRepoName(gitHubParsed.getRepoName());

                JSONObject headObject = (JSONObject) jsonObject.get("head");
                if (headObject != null) {
                    String headSha = str(headObject, "sha");
                    pull.setHeadSha(headSha);
                    pull.setSourceBranch(str(headObject, "ref"));
                    JSONObject headRepoObject = (JSONObject) headObject.get("repo");
                    if (headRepoObject != null) {
                        pull.setSourceRepo(str(headRepoObject, "full_name"));
                    }
                }

                JSONObject baseObject = (JSONObject) jsonObject.get("base");
                if (baseObject != null) {
                    pull.setBaseSha(str(baseObject, "sha"));
                    pull.setTargetBranch(str(baseObject, "ref"));
                    JSONObject baseRepoObject = (JSONObject) baseObject.get("repo");
                    if (baseRepoObject != null) {
                        pull.setTargetRepo(str(baseRepoObject, "full_name"));
                    }
                }

                pull.setCommentsUrl(commentsUrl);
                List<Comment> comments = getComments(commentsUrl, repo);
                pull.setComments(comments);
                pull.setReviewCommentsUrl(reviewCommentsUrl);
                List<CommitStatus> commitStatuses = getCommitStatuses(commitStatusesUrl, repo);
                pull.setCommitStatuses(commitStatuses);
                List<Review> reviews = getReviews(reviewsUrl, repo);
                pull.setReviews(reviews);
                pull.setCommitStatuses(commitStatuses);
                pulls.add(pull);
                stop = (!MapUtils.isEmpty(prMap) && prMap.get(pull.getUpdatedAt()) != null) && (prMap.get(pull.getUpdatedAt()).equals(pull.getNumber()));
                if (stop) {
                    break;
                }
            }
            if (CollectionUtils.isEmpty(jsonArray)) {
                lastPage = true;
            } else {
                if (isThisLastPage(response)) {
                    lastPage = true;
                } else {
                    lastPage = false;
                    queryUrlPage = getNextPageUrl(response);
                }
            }
        }
        return pulls;
    }
382121
private void addRepository(String repositoryId, RepositoryWrapper repositoryHolder) {
        repositories.put(repositoryId, repositoryHolder);
        try {
            numRepos = getNumberOfRepositories();
        } catch (WIMException e) {
            // okay
        }
    }
1168039
private static <S extends Storable> String[] selectNaturalOrder(Repository repo,
                                                                    Class<S> type,
                                                                    Filter<S> filter)
        throws RepositoryException
    {
        if (!filter.isOpen() && repo instanceof RepositoryAccess) {
            UnionQueryAnalyzer.Result result =
                new UnionQueryAnalyzer(type, (RepositoryAccess) repo)
                .analyze(filter, null, QueryHints.emptyHints().with(QueryHint.CONSUME_SLICE));
            OrderingList<S> ordering = result.getTotalOrdering();

            if (ordering == null) {
                List<IndexedQueryAnalyzer.Result> list = result.getSubResults();
                if (!list.isEmpty()) {
                    StorableIndex<S> index = list.get(0).getLocalIndex();
                    if (index != null) {
                        ordering = OrderingList.get(index.getOrderedProperties());
                    }
                }
            }

            if (ordering != null) {
                String[] props = new String[ordering.size()];
                for (int i=0; i<props.length; i++) {
                    props[i] = ordering.get(i).toString();
                }
                return props;
            }
        }

        IndexInfoCapability capability = repo.getCapability(IndexInfoCapability.class);
        if (capability == null) {
            return null;
        }
        IndexInfo info = null;
        for (IndexInfo candidate : capability.getIndexInfo(type)) {
            if (candidate.isClustered()) {
                info = candidate;
                break;
            }
        }
        if (info == null) {
            return null;
        }

        // Verify index is part of primary key.
        Set<String> pkSet = StorableIntrospector.examine(type).getPrimaryKeyProperties().keySet();

        String[] propNames = info.getPropertyNames();
        for (String prop : propNames) {
            if (!pkSet.contains(prop)) {
                return null;
            }
        }

        String[] orderBy = new String[pkSet.size()];

        Direction[] directions = info.getPropertyDirections();

        // Clone to remove elements.
        pkSet = new LinkedHashSet<String>(pkSet);

        int i;
        for (i=0; i<propNames.length; i++) {
            orderBy[i] = ((directions[i] == Direction.DESCENDING) ? "-" : "+") + propNames[i];
            pkSet.remove(propNames[i]);
        }

        // Append any remaining pk properties, to ensure complete ordering.
        if (pkSet.size() > 0) {
            for (String prop : pkSet) {
                orderBy[i++] = prop;
            }
        }

        return orderBy;
    }
632062
public AstRoot parse(Reader sourceReader, String sourceURI, int lineno)
        throws IOException
    {
        if (parseFinished) throw new IllegalStateException("parser reused");
        if (compilerEnv.isIdeMode()) {
            return parse(readFully(sourceReader), sourceURI, lineno);
        }
        try {
            this.sourceURI = sourceURI;
            ts = new TokenStream(this, sourceReader, null, lineno);
            return parse();
        } finally {
            parseFinished = true;
        }
    }
988177
@SuppressWarnings("unchecked")
    void fetchFromRepository(Collection<ProductDefinition> installDefinition) throws RepositoryException {
        Collection<ResourceType> interestingTypes = new HashSet<ResourceType>();
        interestingTypes.add(ResourceType.FEATURE);
        interestingTypes.add(ResourceType.OPENSOURCE);
        interestingTypes.add(ResourceType.PRODUCTSAMPLE);
        Map<ResourceType, Collection<? extends RepositoryResource>> resources = repoConnections.getResources(installDefinition, interestingTypes, null);

        Collection<EsaResource> features = (Collection<EsaResource>) resources.get(ResourceType.FEATURE);
        if (features != null) {
            repoFeatures = features;
        } else {
            repoFeatures = Collections.emptySet();
        }

        repoSamples = new ArrayList<>();
        Collection<SampleResource> samples = (Collection<SampleResource>) resources.get(ResourceType.PRODUCTSAMPLE);
        if (samples != null) {
            repoSamples.addAll(samples);
        }

        Collection<SampleResource> osiSamples = (Collection<SampleResource>) resources.get(ResourceType.OPENSOURCE);
        if (osiSamples != null) {
            repoSamples.addAll(osiSamples);
        }
    }
577795
@GET
    @Path("/repositorysummaries")
    public List<RepositorySummary> getRepositorySummaries() {
        List<RepositorySummary> result = new ArrayList<RepositorySummary>(repositories.size());
        for (String repositoryId : repositories.keySet()) {
            RepositorySummary repositorySummary = getScriptRepo(repositoryId).getRepositorySummary();
            result.add(repositorySummary);
        }
        return result;
    }
456052
public final void parseVersion(String version) {
        versionParts = new ArrayList<>();
        if (version != null) {
            final Pattern rx = Pattern.compile("(\\d+[a-z]{1,3}$|[a-z]+\\d+|\\d+|(release|beta|alpha)$)");
            final Matcher matcher = rx.matcher(version.toLowerCase());
            while (matcher.find()) {
                versionParts.add(matcher.group());
            }
            if (versionParts.isEmpty()) {
                versionParts.add(version);
            }
        }
    }
17520
List<EntityType> putEntitiesInDefaultPackage(
      IntermediateParseResults intermediateResults, String defaultPackageId) {
    Package p = getPackage(intermediateResults, defaultPackageId);
    if (p == null) {
      throw new UnknownPackageException(defaultPackageId);
    }

    List<EntityType> entities = newArrayList();
    for (EntityType entityType : intermediateResults.getEntityTypes()) {
      if (entityType.getPackage() == null) {
        entityType.setId(defaultPackageId + PACKAGE_SEPARATOR + entityType.getId());
        entityType.setPackage(p);
      }
      entities.add(entityType);
    }
    return entities;
  }
880016
def tag(self, repository_tag, tags=[]):
        
        if not isinstance(repository_tag, six.string_types):
            raise TypeError('repository_tag must be a string')

        if not isinstance(tags, list):
            raise TypeError('tags must be a list.')

        if ':' in repository_tag:
            repository, tag = repository_tag.split(':')
            tags.append(tag)
        else:
            repository = repository_tag

            if not tags:
                tags.append('latest')

        for tag in tags:
            repo_tag = "{0}:{1}".format(repository, tag)

            if repo_tag not in self.repo_tags:
                logger.info("Tagging Image: {0} Repo Tag: {1}".format(self.identifier, repo_tag))
                self.repo_tags = self.repo_tags + (repo_tag, )

                # always going to force tags until a feature is added to allow users to specify.
                try:
                    self.client.tag(self.id, repository, tag)
                except:
                    self.client.tag(self.id, repository, tag, force=True)
994372
private void parseRelations(String persistenceUnit, List<TableInfo> tableInfos, EntityMetadata entityMetadata,
            TableInfo tableInfo, List<Relation> relations)
    {
        for (Relation relation : relations)
        {
            if (relation != null)
            {
                Class entityClass = relation.getTargetEntity();
                EntityMetadata targetEntityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                        entityClass);
                if (targetEntityMetadata == null)
                {
                    log.error("Persistence unit for class : " + entityClass + " is not loaded");
                    throw new SchemaGenerationException(
                            "Persistence unit for class : " + entityClass + " is not loaded");
                }
                ForeignKey relationType = relation.getType();

                // if relation type is one to many or join by primary key
                if (targetEntityMetadata != null && relationType.equals(ForeignKey.ONE_TO_MANY)
                        && relation.getJoinColumnName(kunderaMetadata) != null)
                {
                    // if self association
                    if (targetEntityMetadata.equals(entityMetadata))
                    {
                        tableInfo.addColumnInfo(getJoinColumn(tableInfo, relation.getJoinColumnName(kunderaMetadata),
                                entityMetadata.getIdAttribute().getJavaType()));
                    }
                    else
                    {
                        String pu = targetEntityMetadata.getPersistenceUnit();
                        Type targetEntityType = targetEntityMetadata.getType();
                        Class idClass = targetEntityMetadata.getIdAttribute().getJavaType();
                        String idName = ((AbstractAttribute) targetEntityMetadata.getIdAttribute()).getJPAColumnName();
                        TableInfo targetTableInfo = new TableInfo(targetEntityMetadata.getTableName(),
                                targetEntityType.name(), idClass, idName);

                        // In case of different persistence unit. case for poly
                        // glot
                        // persistence.
                        if (!pu.equals(persistenceUnit))
                        {
                            List<TableInfo> targetTableInfos = getSchemaInfo(pu);

                            addJoinColumnToInfo(relation.getJoinColumnName(kunderaMetadata), targetTableInfo,
                                    targetTableInfos, entityMetadata);

                            // add for newly discovered persistence unit.
                            puToSchemaMetadata.put(pu, targetTableInfos);
                        }
                        else
                        {
                            addJoinColumnToInfo(relation.getJoinColumnName(kunderaMetadata), targetTableInfo,
                                    tableInfos, entityMetadata);
                        }
                    }
                }
                // if relation type is one to one or many to one.
                else if (relation.isUnary() && relation.getJoinColumnName(kunderaMetadata) != null)
                {
                    if (!relation.isJoinedByPrimaryKey())
                    {
                        tableInfo.addColumnInfo(getJoinColumn(tableInfo, relation.getJoinColumnName(kunderaMetadata),
                                targetEntityMetadata.getIdAttribute().getJavaType()));
                    }
                }
                // if relation type is many to many and relation via join table.
                else if ((relationType.equals(ForeignKey.MANY_TO_MANY)) && (entityMetadata.isRelationViaJoinTable()))
                {
                    JoinTableMetadata joinTableMetadata = relation.getJoinTableMetadata();
                    String joinTableName = joinTableMetadata != null ? joinTableMetadata.getJoinTableName() : null;
                    String joinColumnName = joinTableMetadata != null
                            ? (String) joinTableMetadata.getJoinColumns().toArray()[0] : null;
                    String inverseJoinColumnName = joinTableMetadata != null
                            ? (String) joinTableMetadata.getInverseJoinColumns().toArray()[0] : null;
                    if (joinTableName != null)
                    {
                        TableInfo joinTableInfo = new TableInfo(joinTableName, Type.COLUMN_FAMILY.name(), String.class,
                                "key");
                        if (!tableInfos.isEmpty() && !tableInfos.contains(joinTableInfo) || tableInfos.isEmpty())
                        {
                            joinTableInfo.addColumnInfo(getJoinColumn(joinTableInfo, joinColumnName,
                                    entityMetadata.getIdAttribute().getJavaType()));
                            joinTableInfo.addColumnInfo(getJoinColumn(joinTableInfo, inverseJoinColumnName,
                                    targetEntityMetadata.getIdAttribute().getJavaType()));

                            // // Do not delete above lines. Currently join
                            // table
                            // columns are of type string only.
                            // // It needs to be fixed later.
                            // joinTableInfo.addColumnInfo(getJoinColumn(joinTableInfo,
                            // joinColumnName, String.class));
                            // joinTableInfo.addColumnInfo(getJoinColumn(joinTableInfo,
                            // inverseJoinColumnName, String.class));

                            tableInfos.add(joinTableInfo);
                        }
                    }
                }
            }
        }
    }