public static ArtificerArtifact visit(ArtifactType artifactType) throws Exception { HibernateEntityCreator visitor = new HibernateEntityCreator(); ArtifactVisitorHelper.visitArtifact(visitor, artifactType.newArtifactInstance()); visitor.throwError(); return visitor.getArtificerArtifact(); }
@Override protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { if (CollectionUtils.isEmpty(arguments)) { return doHelp(commandInvocation); } String pathToContent = optionalArgument(arguments, 0); InputStream contentStream = null; try { ArtifactType artifactType = ArtifactType.valueOf(type); String name = new File(type).getName(); if (pathToContent != null) { File contentFile = new File(pathToContent); contentStream = FileUtils.openInputStream(contentFile); } BaseArtifactType artifact = artifactType.newArtifactInstance(); artifact.setName(name); currentArchive(commandInvocation).addEntry(entryPath, artifact, contentStream); commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.Added", entryPath)); } catch (ArtificerArchiveException e) { commandInvocation.getShell().out().println(Messages.i18n.format("AddEntry.ArtificerArchiveException", e.getLocalizedMessage())); } finally { IOUtils.closeQuietly(contentStream); } return CommandResult.SUCCESS; }
public static BaseArtifactType visit(ArtificerArtifact artificerArtifact, ArtifactType artifactType, boolean includeAssociations) throws Exception { if (artifactType.isExtendedType() && artificerArtifact.isDocument()) { artifactType = ArtifactType.ExtendedDocument(artifactType.getExtendedType()); } BaseArtifactType srampArtifact = artifactType.newArtifactInstance(); HibernateEntityToSrampVisitor visitor = new HibernateEntityToSrampVisitor(artificerArtifact, artifactType, includeAssociations); ArtifactVisitorHelper.visitArtifact(visitor, srampArtifact); visitor.throwError(); return srampArtifact; }
protected CommandResult doExecute(CommandInvocation commandInvocation) throws Exception { ArtificerAtomApiClient client = client(commandInvocation); ArtifactType artifactType = ArtifactType.valueOf(type); if (artifactType.isExtendedType()) { artifactType = ArtifactType.ExtendedArtifactType(artifactType.getExtendedType(), false); } if (artifactType.isDerived()) { commandInvocation.getShell().out().println(Messages.i18n.format("ArtifactModel.isDerived")); return CommandResult.FAILURE; } else if (artifactType.isDocument()) { commandInvocation.getShell().out().println(Messages.i18n.format("ArtifactModel.isDocument")); return CommandResult.FAILURE; } else { BaseArtifactType artifact = artifactType.newArtifactInstance(); artifact.setName(name); artifact.setDescription(description); artifact = client.createArtifact(artifact); // Put the artifact in the session as the active artifact context(commandInvocation).setCurrentArtifact(artifact); } commandInvocation.getShell().out().println(Messages.i18n.format("CreateArtifactCommand.Successful", name)); return CommandResult.SUCCESS; }
BaseArtifactType pomArtifact = ArtifactType.ExtendedDocument(JavaModel.TYPE_MAVEN_POM_XML).newArtifactInstance(); pomArtifact.setName(pomName); ArtificerModelUtils.setCustomProperty(pomArtifact, JavaModel.PROP_MAVEN_TYPE, "pom");