use of org.eclipse.winery.model.ids.Namespace in project winery by eclipse.
the class ServiceTemplateComplianceRuleRuleChecker method getRuleIds.
public List<ComplianceRuleId> getRuleIds(TServiceTemplate serviceTemplate) {
List<ComplianceRuleId> complianceRules = new ArrayList<>();
Namespace namespace = new Namespace(serviceTemplate.getTargetNamespace(), false);
Collection<Namespace> componentsNamespaces = RepositoryFactory.getRepository().getComponentsNamespaces(ComplianceRuleId.class);
List<Namespace> relevantNamespaces = componentsNamespaces.stream().filter(ns -> namespace.getDecoded().startsWith(ns.getDecoded().split("/compliancerules")[0])).collect(Collectors.toList());
for (Namespace space : relevantNamespaces) {
complianceRules.addAll((Collection<? extends ComplianceRuleId>) RepositoryFactory.getRepository().getAllIdsInNamespace(ComplianceRuleId.class, space));
}
return complianceRules;
}
use of org.eclipse.winery.model.ids.Namespace in project winery by eclipse.
the class MultiRepository method generateCommonNamespace.
private static HashSet<Namespace> generateCommonNamespace(Collection<String> repositoryNamespaces) {
HashSet<Namespace> setNS = new HashSet<>();
repositoryNamespaces.forEach(ns -> {
Namespace namespace = new Namespace(ns, false);
if (namespace.getEncoded().contains("%2F")) {
String pns = namespace.getEncoded();
if (namespace.getEncoded().lastIndexOf("%2F") > 15) {
pns = namespace.getEncoded().substring(0, namespace.getEncoded().lastIndexOf("%2F"));
}
setNS.add(new Namespace(pns, true));
}
});
return setNS;
}
use of org.eclipse.winery.model.ids.Namespace in project winery by eclipse.
the class RepositoryUtils method getRepositoriesById.
private static Optional<List<IRepository>> getRepositoriesById(GenericId id, MultiRepository multiRepository) {
List<IRepository> repositoryList = new ArrayList<>();
Optional<Namespace> optNamespace = getNamespaceById(id);
if (optNamespace.isPresent()) {
for (IRepository repo : multiRepository.getRepositoriesMap().keySet()) {
for (String ns : multiRepository.getRepositoriesMap().get(repo)) {
String idNamespace = optNamespace.get().getDecoded();
if (idNamespace.equals(ns)) {
repositoryList.add(repo);
}
}
}
if (!repositoryList.isEmpty()) {
return Optional.of(repositoryList);
}
for (IRepository repo : multiRepository.getRepositoriesCommonNamespace().keySet()) {
for (Namespace ns : multiRepository.getRepositoriesCommonNamespace().get(repo)) {
String idNamespace = optNamespace.get().getDecoded();
String repoNamespace = ns.getDecoded();
if (idNamespace.contains(repoNamespace)) {
repositoryList.add(repo);
}
}
}
}
return repositoryList.isEmpty() ? Optional.of(Collections.singletonList(multiRepository.getRepository())) : Optional.of(repositoryList);
}
Aggregations