Ejemplo n.º 1
0
  /**
   * Show the explorer page
   *
   * @param model
   * @return the view name
   */
  @RequestMapping(method = RequestMethod.GET)
  public String init(
      @RequestParam(value = "dataset", required = false) String selectedEntityName,
      @RequestParam(value = "wizard", required = false) Boolean wizard,
      Model model)
      throws Exception {
    // set entityExplorer URL for link to EntityExplorer for x/mrefs, but only if the user has
    // permission to see the
    // plugin
    if (molgenisPermissionService.hasPermissionOnPlugin(
            EntityExplorerController.ID, Permission.READ)
        || molgenisPermissionService.hasPermissionOnPlugin(
            EntityExplorerController.ID, Permission.WRITE)) {
      model.addAttribute("entityExplorerUrl", EntityExplorerController.ID);
    }

    Iterable<EntityMetaData> entitiesMeta =
        Iterables.transform(
            dataService.getEntityNames(),
            new Function<String, EntityMetaData>() {
              @Override
              public EntityMetaData apply(String entityName) {
                return dataService.getEntityMetaData(entityName);
              }
            });
    model.addAttribute("entitiesMeta", entitiesMeta);

    if (selectedEntityName == null) {
      selectedEntityName = entitiesMeta.iterator().next().getName();
    }
    model.addAttribute("selectedEntityName", selectedEntityName);
    model.addAttribute("wizard", (wizard != null) && wizard.booleanValue());

    // Init genome browser
    model.addAttribute("genomeBrowserSets", getGenomeBrowserSetsToModel());

    String appHrefCss = molgenisSettings.getProperty(KEY_APP_HREF_CSS);
    if (appHrefCss != null) model.addAttribute(KEY_APP_HREF_CSS.replaceAll("\\.", "_"), appHrefCss);

    // including/excluding charts
    Boolean appIncludeCharts =
        molgenisSettings.getBooleanProperty(KEY_APP_INCLUDE_CHARTS, INCLUDE_CHARTS_MODULE);
    model.addAttribute(MODEL_APP_INCLUDE_CHARTS, appIncludeCharts);

    model.addAttribute(INITLOCATION, molgenisSettings.getProperty(INITLOCATION));
    model.addAttribute(COORDSYSTEM, molgenisSettings.getProperty(COORDSYSTEM));
    model.addAttribute(CHAINS, molgenisSettings.getProperty(CHAINS));
    model.addAttribute(SOURCES, molgenisSettings.getProperty(SOURCES));
    model.addAttribute(BROWSERLINKS, molgenisSettings.getProperty(BROWSERLINKS));
    model.addAttribute(SEARCHENDPOINT, molgenisSettings.getProperty(SEARCHENDPOINT));
    model.addAttribute(KARYOTYPEENDPOINT, molgenisSettings.getProperty(KARYOTYPEENDPOINT));
    model.addAttribute(GENOMEBROWSERTABLE, molgenisSettings.getProperty(GENOMEBROWSERTABLE));

    return "view-dataexplorer";
  }
Ejemplo n.º 2
0
  /**
   * @param meta
   * @param attributesSet set of lowercase attribute names to include in response
   * @param attributeExpandsSet set of lowercase attribute names to expand in response
   */
  public EntityMetaDataResponse(
      EntityMetaData meta,
      Set<String> attributesSet,
      Map<String, Set<String>> attributeExpandsSet,
      MolgenisPermissionService permissionService,
      DataService dataService) {
    String name = meta.getName();
    this.href = Href.concatMetaEntityHref(RestController.BASE_URI, name);
    this.hrefCollection =
        String.format("%s/%s", RestController.BASE_URI, name); // FIXME apply Href escaping fix

    if (attributesSet == null || attributesSet.contains("name".toLowerCase())) {
      this.name = name;
    } else this.name = null;

    if (attributesSet == null || attributesSet.contains("description".toLowerCase())) {
      this.description = meta.getDescription();
    } else this.description = null;

    if (attributesSet == null || attributesSet.contains("label".toLowerCase())) {
      label = meta.getLabel();
    } else this.label = null;

    if (attributesSet == null || attributesSet.contains("attributes".toLowerCase())) {
      this.attributes = new LinkedHashMap<String, Object>();

      for (AttributeMetaData attr : meta.getAttributes()) {
        if (!attr.getName().equals("__Type")) {
          if (attributeExpandsSet != null
              && attributeExpandsSet.containsKey("attributes".toLowerCase())) {
            Set<String> subAttributesSet = attributeExpandsSet.get("attributes".toLowerCase());
            this.attributes.put(
                attr.getName(),
                new AttributeMetaDataResponse(
                    name,
                    attr,
                    subAttributesSet,
                    Collections.singletonMap(
                        "refEntity".toLowerCase(), Sets.newHashSet("idattribute")),
                    permissionService,
                    dataService));
          } else {
            String attrHref =
                Href.concatMetaAttributeHref(RestController.BASE_URI, name, attr.getName());
            this.attributes.put(attr.getName(), Collections.singletonMap("href", attrHref));
          }
        }
      }
    } else this.attributes = null;

    if (attributesSet == null || attributesSet.contains("labelAttribute".toLowerCase())) {
      AttributeMetaData labelAttribute = meta.getLabelAttribute();
      this.labelAttribute = labelAttribute != null ? labelAttribute.getName() : null;
    } else this.labelAttribute = null;

    if (attributesSet == null || attributesSet.contains("idAttribute".toLowerCase())) {
      AttributeMetaData idAttribute = meta.getIdAttribute();
      this.idAttribute = idAttribute != null ? idAttribute.getName() : null;
    } else this.idAttribute = null;

    if (attributesSet == null || attributesSet.contains("lookupAttributes".toLowerCase())) {
      Iterable<AttributeMetaData> lookupAttributes = meta.getLookupAttributes();
      this.lookupAttributes =
          lookupAttributes != null
              ? Lists.newArrayList(
                  Iterables.transform(
                      lookupAttributes,
                      new Function<AttributeMetaData, String>() {
                        @Override
                        public String apply(AttributeMetaData attribute) {
                          return attribute.getName();
                        }
                      }))
              : null;
    } else this.lookupAttributes = null;

    if (attributesSet == null || attributesSet.contains("abstract".toLowerCase())) {
      isAbstract = meta.isAbstract();
    } else this.isAbstract = null;

    this.writable =
        permissionService.hasPermissionOnEntity(name, Permission.WRITE)
            && dataService.getCapabilities(name).contains(RepositoryCapability.WRITABLE);
  }