Search in sources :

Example 1 with ProjectInfo

use of eu.esdihumboldt.hale.common.core.io.project.ProjectInfo in project hale by halestudio.

the class TemplateScavengerImpl method onAdd.

@Override
protected void onAdd(TemplateProject reference, String resourceId) {
    reference.update(null);
    Template template;
    try {
        // get existing representation in database
        template = Template.getByTemplateId(graph.get(), resourceId);
    } catch (NonUniqueResultException e) {
        log.error("Duplicate template representation in database");
        return;
    }
    if (template != null) {
        // update valid status
        boolean valid = reference.isValid();
        template.setValid(valid);
        log.info("Updating template {} - {}", resourceId, (valid) ? ("valid") : ("invalid"));
    } else {
        /*
			 * Only create a new database reference if the project actually is
			 * valid
			 */
        if (reference.isValid()) {
            ProjectInfo info = reference.getProjectInfo();
            // create new template representation in DB
            template = Template.create(graph.get());
            // populated with resource ID and values from project
            template.setTemplateId(resourceId);
            template.setName(info.getName());
            template.setAuthor(info.getAuthor());
            template.setDescription(info.getDescription());
            template.setValid(true);
            Date now = new Date();
            template.setCreated(now);
            template.setLastUpdate(now);
            log.info("Creating database representation for template {}", resourceId);
        }
    }
}
Also used : NonUniqueResultException(eu.esdihumboldt.util.blueprints.entities.NonUniqueResultException) ProjectInfo(eu.esdihumboldt.hale.common.core.io.project.ProjectInfo) Date(java.util.Date) Template(eu.esdihumboldt.hale.server.model.Template)

Example 2 with ProjectInfo

use of eu.esdihumboldt.hale.common.core.io.project.ProjectInfo in project hale by halestudio.

the class AbstractProjectDetailsPage method updateFields.

private void updateFields() {
    ProjectWriter writer = getWizard().getProvider();
    if (writer != null && writer.getProject() != null) {
        ProjectInfo p = writer.getProject();
        name.setStringValue(p.getName());
        author.setStringValue(p.getAuthor());
        description.setText((p.getDescription() == null) ? ("") : (p.getDescription()));
    } else {
        name.setStringValue("");
        author.setStringValue("");
        description.setText("");
    }
}
Also used : ProjectWriter(eu.esdihumboldt.hale.common.core.io.project.ProjectWriter) ProjectInfo(eu.esdihumboldt.hale.common.core.io.project.ProjectInfo)

Example 3 with ProjectInfo

use of eu.esdihumboldt.hale.common.core.io.project.ProjectInfo in project hale by halestudio.

the class ProjectProperties method refresh.

@Override
public void refresh() {
    super.refresh();
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    ProjectInfo info = ps.getProjectInfo();
    updateProject = false;
    nameText.setText((info.getName() == null) ? ("") : (info.getName()));
    authorText.setText((info.getAuthor() == null) ? ("") : (info.getAuthor()));
    descriptionText.setText((info.getDescription() == null) ? ("") : (info.getDescription()));
    updateProject = true;
}
Also used : ProjectInfo(eu.esdihumboldt.hale.common.core.io.project.ProjectInfo) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService)

Example 4 with ProjectInfo

use of eu.esdihumboldt.hale.common.core.io.project.ProjectInfo in project hale by halestudio.

the class ProjectCommands method _pinfo.

/**
 * @param ci the command interpreter where this command runs
 */
public synchronized void _pinfo(CommandInterpreter ci) {
    if (projects != null) {
        String project = getProjectArg(ci);
        if (project == null) {
            return;
        }
        ci.println("Project:");
        ci.println("\t" + project);
        ci.println("State:");
        ci.println("\t" + projects.getStatus(project));
        ProjectInfo info = projects.getInfo(project);
        if (info != null) {
            String name = info.getName();
            if (name != null && !name.isEmpty()) {
                ci.println("Name:");
                ci.println("\t" + name);
            }
            String author = info.getAuthor();
            if (author != null && !author.isEmpty()) {
                ci.println("Author:");
                ci.println("\t" + author);
            }
            String description = info.getDescription();
            if (description != null && !description.isEmpty()) {
                ci.println("Description:");
                ci.println("\t" + description);
            }
            Date modified = info.getModified();
            if (modified != null) {
                ci.println("Last modified:");
                ci.println("\t" + DateFormat.getDateTimeInstance().format(modified));
            }
            Date created = info.getCreated();
            if (created != null) {
                ci.println("Created:");
                ci.println("\t" + DateFormat.getDateTimeInstance().format(created));
            }
            Version version = info.getHaleVersion();
            if (version != null) {
                ci.println("HALE version:");
                ci.println("\t" + version);
            }
        }
    }
}
Also used : Version(org.osgi.framework.Version) ProjectInfo(eu.esdihumboldt.hale.common.core.io.project.ProjectInfo) Date(java.util.Date)

Example 5 with ProjectInfo

use of eu.esdihumboldt.hale.common.core.io.project.ProjectInfo in project hale by halestudio.

the class ExamplesContent method getMappingContent.

/**
 * Get the mapping documentation content for an example project.
 *
 * @param projectId the project ID
 * @return the mapping documentation content stream or <code>null</code>
 */
private InputStream getMappingContent(String projectId) {
    if (!mappingDocExportInitialized) {
        mappingDocExport = HaleIO.createIOProvider(AlignmentWriter.class, null, ID_MAPPING_EXPORT);
        if (mappingDocExport == null) {
            log.error("Could not create mapping documentation exporter.");
        }
        mappingDocExportInitialized = true;
    }
    if (mappingDocExport == null) {
        // no mapping documentation export possible
        return null;
    }
    if (tempMappingDir == null) {
        tempMappingDir = Files.createTempDir();
        tempMappingDir.deleteOnExit();
    }
    // the file of the mapping documentation
    File mappingDoc = new File(tempMappingDir, projectId + ".html");
    if (!mappingDoc.exists()) {
        ATransaction trans = log.begin("Generate example mapping documentation");
        try {
            // create the mapping documentation
            ExampleProject exampleProject = ExampleProjectExtension.getInstance().get(projectId);
            final Project project = (Project) exampleProject.getInfo();
            // determine alignment location - contained in project file, not
            // a resource
            URI alignmentLoc = exampleProject.getAlignmentLocation();
            if (alignmentLoc == null) {
                // no alignment present
                return null;
            }
            // store configurations per action ID
            Multimap<String, IOConfiguration> confs = HashMultimap.create();
            for (IOConfiguration conf : project.getResources()) {
                confs.put(conf.getActionId(), conf);
            }
            // load schemas
            // source schemas
            LoadSchemaAdvisor source = new LoadSchemaAdvisor(SchemaSpaceID.SOURCE);
            for (IOConfiguration conf : confs.get(SchemaIO.ACTION_LOAD_SOURCE_SCHEMA)) {
                source.setConfiguration(conf);
                executeProvider(source, conf.getProviderId(), null);
            }
            // target schemas
            LoadSchemaAdvisor target = new LoadSchemaAdvisor(SchemaSpaceID.TARGET);
            for (IOConfiguration conf : confs.get(SchemaIO.ACTION_LOAD_TARGET_SCHEMA)) {
                target.setConfiguration(conf);
                executeProvider(target, conf.getProviderId(), null);
            }
            // load alignment
            // manual loading needed, as we can't rely on the environment
            // alignment advisor
            DefaultInputSupplier alignmentIn = new DefaultInputSupplier(alignmentLoc);
            AlignmentReader reader = HaleIO.findIOProvider(AlignmentReader.class, alignmentIn, alignmentLoc.getPath());
            LoadAlignmentAdvisor alignmentAdvisor = new LoadAlignmentAdvisor(null, source.getSchemaSpace(), target.getSchemaSpace(), exampleProject.getUpdater());
            reader.setSource(alignmentIn);
            executeProvider(alignmentAdvisor, null, reader);
            Alignment alignment = alignmentAdvisor.getAlignment();
            if (alignment != null) {
                // save alignment docu
                synchronized (mappingDocExport) {
                    // only a single instance
                    mappingDocExport.setAlignment(alignment);
                    mappingDocExport.setTarget(new FileIOSupplier(mappingDoc));
                    if (mappingDocExport instanceof ProjectInfoAware) {
                        ProjectInfo smallInfo = new ProjectInfo() {

                            @Override
                            public String getName() {
                                return project.getName();
                            }

                            @Override
                            public Date getModified() {
                                return null;
                            }

                            @Override
                            public Version getHaleVersion() {
                                return null;
                            }

                            @Override
                            public String getDescription() {
                                return project.getDescription();
                            }

                            @Override
                            public Date getCreated() {
                                return null;
                            }

                            @Override
                            public String getAuthor() {
                                return project.getAuthor();
                            }
                        };
                        // project);
                        ((ProjectInfoAware) mappingDocExport).setProjectInfo(smallInfo);
                    }
                    mappingDocExport.execute(null);
                }
                mappingDoc.deleteOnExit();
            }
        } catch (Throwable e) {
            log.error("Error generating mapping documentation for example project", e);
            return null;
        } finally {
            trans.end();
        }
    }
    if (mappingDoc.exists()) {
        try {
            return new FileInputStream(mappingDoc);
        } catch (FileNotFoundException e) {
            return null;
        }
    } else
        return null;
}
Also used : AlignmentReader(eu.esdihumboldt.hale.common.align.io.AlignmentReader) DefaultInputSupplier(eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier) IOConfiguration(eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration) FileNotFoundException(java.io.FileNotFoundException) ExampleProject(eu.esdihumboldt.hale.doc.user.examples.internal.extension.ExampleProject) URI(java.net.URI) ProjectInfoAware(eu.esdihumboldt.hale.common.core.io.project.ProjectInfoAware) FileInputStream(java.io.FileInputStream) ExampleProject(eu.esdihumboldt.hale.doc.user.examples.internal.extension.ExampleProject) Project(eu.esdihumboldt.hale.common.core.io.project.model.Project) Alignment(eu.esdihumboldt.hale.common.align.model.Alignment) ATransaction(de.fhg.igd.slf4jplus.ATransaction) ProjectInfo(eu.esdihumboldt.hale.common.core.io.project.ProjectInfo) FileIOSupplier(eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier) LoadSchemaAdvisor(eu.esdihumboldt.hale.common.schema.io.impl.LoadSchemaAdvisor) LoadAlignmentAdvisor(eu.esdihumboldt.hale.common.align.io.impl.LoadAlignmentAdvisor) File(java.io.File) AlignmentWriter(eu.esdihumboldt.hale.common.align.io.AlignmentWriter)

Aggregations

ProjectInfo (eu.esdihumboldt.hale.common.core.io.project.ProjectInfo)6 ProjectService (eu.esdihumboldt.hale.ui.service.project.ProjectService)2 Date (java.util.Date)2 ATransaction (de.fhg.igd.slf4jplus.ATransaction)1 AlignmentReader (eu.esdihumboldt.hale.common.align.io.AlignmentReader)1 AlignmentWriter (eu.esdihumboldt.hale.common.align.io.AlignmentWriter)1 LoadAlignmentAdvisor (eu.esdihumboldt.hale.common.align.io.impl.LoadAlignmentAdvisor)1 Alignment (eu.esdihumboldt.hale.common.align.model.Alignment)1 ProjectInfoAware (eu.esdihumboldt.hale.common.core.io.project.ProjectInfoAware)1 ProjectWriter (eu.esdihumboldt.hale.common.core.io.project.ProjectWriter)1 IOConfiguration (eu.esdihumboldt.hale.common.core.io.project.model.IOConfiguration)1 Project (eu.esdihumboldt.hale.common.core.io.project.model.Project)1 Resource (eu.esdihumboldt.hale.common.core.io.project.model.Resource)1 DefaultInputSupplier (eu.esdihumboldt.hale.common.core.io.supplier.DefaultInputSupplier)1 FileIOSupplier (eu.esdihumboldt.hale.common.core.io.supplier.FileIOSupplier)1 LoadSchemaAdvisor (eu.esdihumboldt.hale.common.schema.io.impl.LoadSchemaAdvisor)1 ExampleProject (eu.esdihumboldt.hale.doc.user.examples.internal.extension.ExampleProject)1 Template (eu.esdihumboldt.hale.server.model.Template)1 ProjectServiceAdapter (eu.esdihumboldt.hale.ui.service.project.ProjectServiceAdapter)1 ViewerMenu (eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)1