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(" "); }
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(" "); } }
@Nullable public static Integer compare(@NotNull Visibility first, @NotNull Visibility second) { Integer result = first.compareTo(second); if (result != null) { return result; } Integer oppositeResult = second.compareTo(first); if (oppositeResult != null) { return -oppositeResult; } return null; }
private void initializeProperties() { setProperty(PROP_SOURCE_NAME, ""); setProperty(PROP_TARGET_NAME, ""); setProperty(PROP_SOURCE_VISIBILITY, ""); setProperty(PROP_TARGET_VISIBILITY, ""); setProperty(PROP_SOURCE_MULTIPLICITY, "1..*"); setProperty(PROP_TARGET_MULTIPLICITY, "1..*"); setProperty(PROP_DIRECTION, DIRECTION_TARGET); String[] direction = {DIRECTION_NONE, DIRECTION_SOURCE, DIRECTION_TARGET, DIRECTION_BOTH}; setPropertyEditor(PROP_DIRECTION, new ListSelectionPropertyEditor(direction)); setPropertyEditor( PROP_SOURCE_VISIBILITY, new ListSelectionPropertyEditor(Visibility.stringValues())); setPropertyEditor( PROP_TARGET_VISIBILITY, new ListSelectionPropertyEditor(Visibility.stringValues())); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((value == null) ? 0 : value.hashCode()); result = prime * result + ((visibility == null) ? 0 : visibility.hashCode()); return result; }
private static void checkVisibility( @NotNull DeclarationDescriptorWithVisibility descriptor, @NotNull BindingTrace trace, @NotNull JetSimpleNameExpression referenceExpression, @NotNull JetScope scopeToCheckVisibility) { if (!Visibilities.isVisible( ReceiverValue.IRRELEVANT_RECEIVER, descriptor, scopeToCheckVisibility.getContainingDeclaration())) { Visibility visibility = descriptor.getVisibility(); if (PsiTreeUtil.getParentOfType(referenceExpression, JetImportDirective.class) != null && !visibility.mustCheckInImports()) return; //noinspection ConstantConditions trace.report( INVISIBLE_REFERENCE.on( referenceExpression, descriptor, visibility, descriptor.getContainingDeclaration())); } }
/** * Returns all program element docs that have a visibility greater or equal than the specified * level */ private <T extends ProgramElementDoc> List<T> filterByVisibility( T[] docs, Visibility visibility) { if (visibility == Visibility.PRIVATE) return Arrays.asList(docs); List<T> filtered = new ArrayList<T>(); for (T doc : docs) { if (Visibility.get(doc).compareTo(visibility) > 0) filtered.add(doc); } return filtered; }
@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(); }
@Override public boolean isVisible( @NotNull ReceiverValue thisObject, @NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) { if (PRIVATE.isVisible(thisObject, what, from)) { DeclarationDescriptor classDescriptor = DescriptorUtils.getParentOfType(what, ClassDescriptor.class); if (classDescriptor != null && thisObject instanceof ClassReceiver) { return ((ClassReceiver) thisObject).getDeclarationDescriptor().getOriginal() == classDescriptor.getOriginal(); } } return false; }
static void load(URL u) { base = u; try { loadSystems(); } catch (Exception e) { MiscUI.user_fatal("Error loading systems.", e); } try { loadJumps(); } catch (Exception e) { MiscUI.user_fatal("Error loading jumps.", e); } try { loadConstellations(); } catch (Exception e) { MiscUI.user_error("Error loading constellations.", e); } try { loadRegions(); } catch (Exception e) { MiscUI.user_error("Error loading regions.", e); } try { loadStations(); } catch (Exception e) { MiscUI.user_error("Error loading stations.", e); } try { loadIcons(); } catch (Exception e) { MiscUI.user_error("Error loading icons.", e); } try { loadHelp(); } catch (Exception e) { MiscUI.user_error("Error loading help.", e); } try { loadBuildNumber(); } catch (Exception e) { MiscUI.user_error("Error loading build number.", e); } if (buildNumber == -1) MiscUI.user_error("Error loading build number.", null); Visibility.updateVisibles(); }
@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; }
@Override protected boolean isVisible( @NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) { return PROTECTED.isVisible(what, from) && INTERNAL.isVisible(what, from); }
public Visibility getVisibility() { return Visibility.valueOf(visibility.getFragment()); }
public void setVisibility(Visibility visibility) { this.visibility = URI.create("http://imeji.org/terms/visibility#" + visibility.name()); }
public static void main(String[] args) { Visibility.test(); // Synchronized.test(); // Reordering.test(); }
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; }
private ColumnVisibility visibilityToAccumuloVisibility(Visibility visibility) { return new ColumnVisibility(visibility.getVisibilityString()); }
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; }