Package fr.openwide.maven.artifact.notifier.core.business.search.model

Examples of fr.openwide.maven.artifact.notifier.core.business.search.model.ArtifactBean


          public void onClick(AjaxRequestTarget target) {
            try {
              FollowedArtifact followedArtifact = getModelObject();
              if (followedArtifact != null) {
                userService.unfollowArtifact(MavenArtifactNotifierSession.get().getUser(), followedArtifact);
                backupArtifactBeanModel.setObject(new ArtifactBean(followedArtifact));
                followedArtifactModel.setObject(null);
                target.add(DashboardArtifactPortfolioPanel.this);
                getSession().success(getString("artifact.delete.success"));
              } else {
                getSession().warn(getString("artifact.delete.notFollowed"));
View Full Code Here


    alertContainer.add(new ListView<ArtifactBean>("invalidArtifacts", invalidArtifactsModel) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void populateItem(ListItem<ArtifactBean> item) {
        ArtifactBean artifactBean = item.getModelObject();
        item.add(new Label("artifactUniqueId", String.format("%s:%s", artifactBean.getGroupId(), artifactBean.getArtifactId())));
      }
    });
    add(alertContainer);
  }
View Full Code Here

 
  private List<ArtifactBean> populate(Elements elements) {
    List<ArtifactBean> artifactList = Lists.newArrayList();
    for (Element dependency : elements) {
     
      ArtifactBean artifactBean = new ArtifactBean();
      for (Element child : dependency.children()) {
        if (child.nodeName().compareTo("groupid") == 0) {
          artifactBean.setGroupId(child.text());
        } else if (child.nodeName().compareTo("artifactid") == 0) {
          artifactBean.setArtifactId(child.text());
        } else if (child.nodeName().compareTo("type") == 0) {
          artifactBean.setType(child.text());
        }
      }
     
      if (StringUtils.hasText(artifactBean.getGroupId()) && StringUtils.hasText(artifactBean.getArtifactId())) {
        artifactBean.setId(artifactBean.getGroupId() + ":" + artifactBean.getArtifactId());
        artifactList.add(artifactBean);
      }
    }
   
    Collections.sort(artifactList);
View Full Code Here

  @Override
  protected void populateItem(final Item<ArtifactBean> item) {
    item.setOutputMarkupId(true);
   
    ArtifactBean artifactBean = item.getModelObject();

    final ArtifactModel artifactModel = new ArtifactModel(Model.of(item.getModelObject().getArtifactKey()));
    final ArtifactLastVersionModel artifactLastVersionModel = new ArtifactLastVersionModel(artifactModel);
   
    item.add(new ClassAttributeAppender(new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;
     
      @Override
      protected String load() {
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isFollowed = user != null && userService.isFollowedArtifactBean(user, item.getModelObject());
        boolean isDeprecated = artifactModel.getObject() != null &&
            ArtifactDeprecationStatus.DEPRECATED.equals(artifactModel.getObject().getDeprecationStatus());
        return isFollowed ? "success" : (isDeprecated ? "warning" : null);
      }
    }));
   
    // GroupId column
    item.add(new Label("groupId", new PropertyModel<ArtifactBean>(item.getModel(), "groupId")));
    item.add(new ExternalLink("groupLink", mavenCentralSearchUrlService.getGroupUrl(artifactBean.getGroupId())));

    // ArtifactId column
    Link<Void> localArtifactLink = ArtifactDescriptionPage.linkDescriptor(artifactModel).link("localArtifactLink");
    // Not done in the onConfigure method because if the model changes the link's PageParameters need to be reconstructed and so does the page.
    localArtifactLink.setEnabled(artifactModel.getObject() != null);
    localArtifactLink.add(new Label("artifactId", new PropertyModel<ArtifactBean>(item.getModel(), "artifactId")));
    item.add(localArtifactLink);
   
    item.add(new ExternalLink("artifactLink", mavenCentralSearchUrlService.getArtifactUrl(artifactBean.getGroupId(), artifactBean.getArtifactId())));
   
    // LastVersion and lastUpdateDate columns
    item.add(new Label("unfollowedArtifactPlaceholder", new ResourceModel("artifact.follow.unfollowedArtifact")) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(artifactModel.getObject() == null);
      }
    });
    item.add(new Label("synchronizationPlannedPlaceholder", new ResourceModel("artifact.follow.synchronizationPlanned")) {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(artifactModel.getObject() != null && !artifactLastVersionModel.isLastVersionAvailable());
      }
    });
   
    WebMarkupContainer localContainer = new WebMarkupContainer("followedArtifact") {
      private static final long serialVersionUID = 1L;

      @Override
      protected void onConfigure() {
        super.onConfigure();
        setVisible(artifactLastVersionModel.isLastVersionAvailable());
      }
    };
    localContainer.add(new ArtifactVersionTagPanel("latestVersion", Model.of(artifactLastVersionModel.getLastVersion())));
    localContainer.add(new ExternalLink("versionLink", mavenCentralSearchUrlService.getVersionUrl(artifactBean.getGroupId(),
        artifactBean.getArtifactId(), artifactBean.getLatestVersion())));
    localContainer.add(new DateLabelWithPlaceholder("lastUpdateDate", Model.of(artifactLastVersionModel.getLastVersionUpdateDate()), DatePattern.SHORT_DATE));
    item.add(localContainer);

    // Followers count column
    Label followersCount = new CountLabel("followersCount", "artifact.follow.dataView.followers",
        BindingModel.of(artifactModel, Binding.artifact().followersCount()));
    followersCount.add(new AttributeModifier("class", new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;

      @Override
      protected String load() {
        if (artifactModel.getObject() != null && artifactModel.getObject().getFollowersCount() > 0) {
          return "badge";
        }
        return null;
      }
    }));
    item.add(followersCount);
   
    // Follow column
    AjaxLink<ArtifactBean> follow = new AjaxLink<ArtifactBean>("follow", item.getModel()) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          userService.followArtifactBean(MavenArtifactNotifierSession.get().getUser(), getModelObject());
          refresh(target, item);
        } catch (AlreadyFollowedArtifactException e) {
          getSession().warn(getString("artifact.follow.alreadyFollower"));
          refresh(target, item);
        } catch (Exception e) {
          LOGGER.error("Error occured while following artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        ArtifactBean artifactBean = getModelObject();
        Artifact artifact = artifactModel.getObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = artifact != null && ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());

        setVisible(!isDeprecated && user != null && artifactBean != null && !userService.isFollowedArtifactBean(user, artifactBean));
      }
    };
    follow.add(new AuthenticatedOnlyBehavior());
    item.add(follow);
   
    final IModel<Artifact> relatedArtifactModel = BindingModel.of(artifactModel, Binding.artifact().relatedArtifact());
    Link<Void> relatedArtifactLink = ArtifactDescriptionPage.linkDescriptor(relatedArtifactModel).link("relatedArtifactLink");
    relatedArtifactLink.add(new Behavior() {
      private static final long serialVersionUID = 1L;

      @Override
      public void onConfigure(Component component) {
        super.onConfigure(component);
        ArtifactBean artifactBean = item.getModelObject();
        Artifact artifact = artifactModel.getObject();
        User user = MavenArtifactNotifierSession.get().getUser();
        boolean isDeprecated = (artifact != null) && ArtifactDeprecationStatus.DEPRECATED.equals(artifact.getDeprecationStatus());
       
        component.setVisibilityAllowed(isDeprecated && user != null && artifactBean != null && !userService.isFollowedArtifactBean(user, artifactBean));
View Full Code Here

TOP

Related Classes of fr.openwide.maven.artifact.notifier.core.business.search.model.ArtifactBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.