示例#1
0
 private void renderVisibility(@NotNull Visibility visibility, @NotNull StringBuilder builder) {
   if (!modifiers.contains(Modifier.VISIBILITY)) return;
   if (normalizedVisibilities) {
     visibility = visibility.normalize();
   }
   if (!showInternalKeyword && visibility == Visibilities.INTERNAL) return;
   builder.append(renderKeyword(visibility.toString())).append(" ");
 }
示例#2
0
 private void renderVisibility(Visibility visibility, StringBuilder builder) {
   if (!shouldRenderModifiers()) return;
   if ("package".equals(visibility.toString())) {
     builder.append("public/*package*/ ");
   } else {
     builder.append(renderKeyword(visibility.toString())).append(" ");
   }
 }
示例#3
0
 @Nullable
 private static Visibility computeVisibilityToInherit(
     @NotNull CallableMemberDescriptor memberDescriptor) {
   Collection<? extends CallableMemberDescriptor> overriddenDescriptors =
       memberDescriptor.getOverriddenDescriptors();
   Visibility maxVisibility = findMaxVisibility(overriddenDescriptors);
   if (maxVisibility == null) {
     return null;
   }
   if (memberDescriptor.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
     for (CallableMemberDescriptor overridden : overriddenDescriptors) {
       // An implementation (a non-abstract overridden member) of a fake override should have the
       // maximum possible visibility
       if (overridden.getModality() != Modality.ABSTRACT
           && !overridden.getVisibility().equals(maxVisibility)) {
         return null;
       }
     }
     return maxVisibility;
   }
   return maxVisibility.normalize();
 }
示例#4
0
 @Override
 public Property getProperty(String key, String name, Visibility visibility) {
   if (ID_PROPERTY_NAME.equals(name)) {
     return getIdProperty();
   } else if (Edge.LABEL_PROPERTY_NAME.equals(name) && this instanceof Edge) {
     return getEdgeLabelProperty();
   }
   for (Property p : getProperties()) {
     if (!p.getKey().equals(key)) {
       continue;
     }
     if (!p.getName().equals(name)) {
       continue;
     }
     if (visibility == null) {
       return p;
     }
     if (!visibility.equals(p.getVisibility())) {
       continue;
     }
     return p;
   }
   return null;
 }
示例#5
0
  protected PartData retrieveEntryDetails(String userId, Entry entry) {
    // user must be able to read if not public entry
    if (!permissionsController.isPubliclyVisible(entry)) authorization.expectRead(userId, entry);

    PartData partData = ModelToInfoFactory.getInfo(entry);
    if (partData == null) return null;
    boolean hasSequence = sequenceDAO.hasSequence(entry.getId());

    partData.setHasSequence(hasSequence);
    boolean hasOriginalSequence = sequenceDAO.hasOriginalSequence(entry.getId());
    partData.setHasOriginalSequence(hasOriginalSequence);

    // permissions
    partData.setCanEdit(authorization.canWriteThoroughCheck(userId, entry));
    partData.setPublicRead(permissionsController.isPubliclyVisible(entry));

    // create audit event if not owner
    // todo : remote access check
    if (userId != null
        && authorization.getOwner(entry) != null
        && !authorization.getOwner(entry).equalsIgnoreCase(userId)) {
      try {
        Audit audit = new Audit();
        audit.setAction(AuditType.READ.getAbbrev());
        audit.setEntry(entry);
        audit.setUserId(userId);
        audit.setLocalUser(true);
        audit.setTime(new Date(System.currentTimeMillis()));
        auditDAO.create(audit);
      } catch (Exception e) {
        Logger.error(e);
      }
    }

    // retrieve more information about linked entries if any (default only contains id)
    if (partData.getLinkedParts() != null) {
      ArrayList<PartData> newLinks = new ArrayList<>();
      for (PartData link : partData.getLinkedParts()) {
        Entry linkedEntry = dao.get(link.getId());
        if (!authorization.canRead(userId, linkedEntry)) continue;

        link = ModelToInfoFactory.createTipView(linkedEntry);
        Sequence sequence = sequenceDAO.getByEntry(linkedEntry);
        if (sequence != null) {
          link.setBasePairCount(sequence.getSequence().length());
          link.setFeatureCount(sequence.getSequenceFeatures().size());
        }

        newLinks.add(link);
      }
      partData.getLinkedParts().clear();
      partData.getLinkedParts().addAll(newLinks);
    }

    // check if there is a parent available
    List<Entry> parents = dao.getParents(entry.getId());
    if (parents == null) return partData;

    for (Entry parent : parents) {
      if (!authorization.canRead(userId, parent)) continue;

      if (parent.getVisibility() != Visibility.OK.getValue()
          && !authorization.canWriteThoroughCheck(userId, entry)) continue;

      EntryType type = EntryType.nameToType(parent.getRecordType());
      PartData parentData = new PartData(type);
      parentData.setId(parent.getId());
      parentData.setName(parent.getName());
      parentData.setVisibility(Visibility.valueToEnum(parent.getVisibility()));
      partData.getParents().add(parentData);
    }

    return partData;
  }
示例#6
0
  private static Entry setCommon(Entry entry, PartData info) {
    if (entry == null || info == null) return null;

    if (info.getName() != null) entry.setName(info.getName());

    if (info.getSelectionMarkers() != null) {
      Set<SelectionMarker> markers = getSelectionMarkers(info.getSelectionMarkers(), entry);
      entry.setSelectionMarkers(markers);
    }

    if (info.getReferences() != null) entry.setReferences(info.getReferences());

    if (StringUtils.isBlank(entry.getPartNumber())) entry.setPartNumber(info.getPartId());

    Date currentTime = new Date();
    if (entry.getCreationTime() == null) entry.setCreationTime(currentTime);

    entry.setModificationTime(currentTime);

    if (info.getOwnerEmail() != null) {
      entry.setOwnerEmail(info.getOwnerEmail());
    }

    if (info.getOwner() != null) entry.setOwner(info.getOwner());

    if (info.getCreatorEmail() != null) {
      entry.setCreatorEmail(info.getCreatorEmail());
    }

    if (info.getCreator() != null) entry.setCreator(info.getCreator());

    if (info.getStatus() == null) {
      if (StringUtils.isBlank(entry.getStatus())) entry.setStatus("");
    } else entry.setStatus(info.getStatus());

    if (info.getAlias() != null) entry.setAlias(info.getAlias());

    if (info.getBioSafetyLevel() == null) {
      if (entry.getBioSafetyLevel() == null) entry.setBioSafetyLevel(0);
    } else entry.setBioSafetyLevel(info.getBioSafetyLevel());

    if (info.getShortDescription() != null) entry.setShortDescription(info.getShortDescription());
    if (info.getLongDescription() != null) entry.setLongDescription(info.getLongDescription());
    if (info.getIntellectualProperty() != null)
      entry.setIntellectualProperty(info.getIntellectualProperty());

    Set<Link> links = getLinks(info.getLinks(), entry);
    entry.setLinks(links);

    Visibility visibility = info.getVisibility();
    if (visibility != null) entry.setVisibility(visibility.getValue());

    // checking for null instead of blank since it could be cleared
    if (info.getFundingSource() != null) entry.setFundingSource(info.getFundingSource());
    if (info.getPrincipalInvestigator() != null)
      entry.setPrincipalInvestigator(info.getPrincipalInvestigator());
    if (info.getPrincipalInvestigatorEmail() != null)
      entry.setPrincipalInvestigatorEmail(info.getPrincipalInvestigatorEmail());

    if (info.getKeywords() != null) entry.setKeywords(info.getKeywords());

    // parameters
    List<Parameter> parameters = getParameters(info.getCustomFields(), entry);
    entry.setParameters(parameters);
    return entry;
  }