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

Examples of fr.openwide.maven.artifact.notifier.core.business.artifact.model.Artifact


    projectForm.add(new AjaxSubmitLink("addToProject", projectForm) {
      private static final long serialVersionUID = 1L;
     
      @Override
      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
        Artifact artifact = ArtifactProjectPanel.this.getModelObject();
        Project selectedProject = projectDropDown.getModelObject();
       
        if (selectedProject != null) {
          if (artifact.getProject() == null) {
            try {
              projectService.addArtifact(selectedProject, artifact);
              getSession().success(getString("artifact.project.add.success"));
            } catch (Exception e) {
              LOGGER.error("Unknown error occured while adding an artifact to a project", e);
View Full Code Here


    AjaxButton validate = new AjaxButton("save", form) {
      private static final long serialVersionUID = 1L;
     
      @Override
      protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
        Artifact artifact = ArtifactDeprecationFormPopupPanel.this.getModelObject();
       
        try {
          if (artifact != null) {
            if (ArtifactDeprecationStatus.NORMAL.equals(artifact.getDeprecationStatus())) {
              artifact.setRelatedArtifact(null);
            }
            artifactService.update(artifact);
            getSession().success(getString("artifact.deprecation.success"));
          }
          closePopup(target);
View Full Code Here

     
      @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));
        component.setEnabled(relatedArtifactModel.getObject() != null);
      }
    });
    relatedArtifactLink.add(new AuthenticatedOnlyBehavior());
    relatedArtifactLink.add(new AttributeModifier("title", new LoadableDetachableModel<String>() {
      private static final long serialVersionUID = 1L;

      @Override
      protected String load() {
        Artifact relatedArtifact = relatedArtifactModel.getObject();
        StringBuilder sb = new StringBuilder(getString("artifact.description.deprecated"));
        if (relatedArtifact != null) {
          sb.append(" ").append(getString("artifact.deprecation.link.title", relatedArtifactModel));
        }
        return sb.toString();
      }
    }));
    item.add(relatedArtifactLink);
   
    AjaxLink<Artifact> unfollow = new AjaxLink<Artifact>("unfollow", artifactModel) {
      private static final long serialVersionUID = 1L;
     
      @Override
      public void onClick(AjaxRequestTarget target) {
        try {
          if (!userService.unfollowArtifact(MavenArtifactNotifierSession.get().getUser(), getModelObject())) {
            getSession().warn(getString("artifact.delete.notFollowed"));
          }
          refresh(target, item);
        } catch (Exception e) {
          LOGGER.error("Error occured while unfollowing artifact", e);
          getSession().error(getString("common.error.unexpected"));
        }
        FeedbackUtils.refreshFeedback(target, getPage());
      }
     
      @Override
      protected void onConfigure() {
        super.onConfigure();
        Artifact artifact = getModelObject();
        User user = MavenArtifactNotifierSession.get().getUser();
       
        setVisible(user != null && artifact != null && userService.isFollowedArtifact(user, artifact));
      }
    };
View Full Code Here

    {
      ArtifactGroup group = new ArtifactGroup("org.apache.commons");
      artifactGroupService.create(group);

      Artifact artifact = new Artifact("commons-exec");
      group.addArtifact(artifact);
      artifactService.create(artifact);

      User user = new User();
      user.setUserName("firstname.lastname@test.fr");
      user.setEmail(user.getUserName());
      userService.create(user);
     
      Calendar previousDate = GregorianCalendar.getInstance();
      previousDate.set(GregorianCalendar.DAY_OF_MONTH, -1);
     
      userService.followArtifact(user, artifact);
      user.getFollowedArtifacts().get(0).setLastNotifiedVersionDate(previousDate.getTime());
      artifact.setStatus(ArtifactStatus.INITIALIZED);
     
      ArtifactVersion artifactVersion = new ArtifactVersion("2.0-test", new Date());
      artifactVersionService.create(artifactVersion);
      artifact.addVersion(artifactVersion);
    }
    mavenSynchronizationService.synchronizeAllArtifactsAndNotifyUsers();

    User testUser = userService.getByUserName("firstname.lastname@test.fr");
    assertTrue(!testUser.getFollowedArtifacts().isEmpty());
View Full Code Here

   
    {
      ArtifactGroup group = new ArtifactGroup("com.google.inject");
      artifactGroupService.create(group);
     
      Artifact artifact = new Artifact("guice");
      group.addArtifact(artifact);
      artifactService.create(artifact);
     
      User user = new User();
      user.setUserName("firstname.lastname@test.fr");
      user.setEmail(user.getUserName());
      userService.create(user);

      userService.followArtifact(user, artifact);
    }
   
    List<Artifact> artifactList = artifactService.list();
   
    assertEquals(1, artifactList.size());
    Artifact artifact = artifactList.get(0);
    assertEquals("com.google.inject", artifact.getGroup().getGroupId());
    assertEquals("guice", artifact.getArtifactId());
    assertEquals(ArtifactStatus.NOT_INITIALIZED, artifact.getStatus());
   
    mavenSynchronizationService.synchronizeAllArtifactsAndNotifyUsers();
    assertEquals(ArtifactStatus.INITIALIZED, artifact.getStatus());
    assertTrue(artifact.getVersions().size() > 0);
    ArtifactVersion firstVersion = (ArtifactVersion) artifact.getVersions().toArray()[artifact.getVersions().size() - 1];
    assertEquals("1.0", firstVersion.getVersion());
  }
View Full Code Here

  public void inject(PageParameters targetParameters, ILinkParameterConversionService conversionService)
      throws LinkParameterInjectionException {
    Args.notNull(targetParameters, "targetParameters");
    Args.notNull(conversionService, "conversionService");
   
    Artifact artifact = artifactModel.getObject();
   
    if (artifact != null) {
      if (artifact.getGroup() != null && artifact.getGroup().getGroupId() != null) {
        targetParameters.add(GROUP_ID_PARAMETER, artifact.getGroup().getGroupId());
      }
      if (artifact.getArtifactId() != null) {
        targetParameters.add(ARTIFACT_ID_PARAMETER, artifact.getArtifactId());
      }
    }
  }
View Full Code Here

    Args.notNull(conversionService, "conversionService");
   
    String groupId = sourceParameters.get(GROUP_ID_PARAMETER).toString();
    String artifactId = sourceParameters.get(ARTIFACT_ID_PARAMETER).toString();
   
    Artifact artifact = null;
    if (groupId != null && artifactId != null) {
      ArtifactKey artifactKey = new ArtifactKey(groupId, artifactId);
     
      try {
        artifact = conversionService.convert(artifactKey, Artifact.class);
View Full Code Here

TOP

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

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.