Package com.buschmais.jqassistant.core.store.api

Examples of com.buschmais.jqassistant.core.store.api.Store


    @Override
    public Continuation execute(AppCommandParser parser, Session session, final Output out) throws Exception {
        RuleSet effectiveRuleSet = getEffectiveRuleSet(parser);
        InMemoryReportWriter reportWriter = new InMemoryReportWriter();
        Store store = getStore();
        store.start(getScannerPluginRepository().getDescriptorTypes());
        ShellConsole console = new ShellConsole(out);
        Analyzer analyzer = new AnalyzerImpl(store, reportWriter, console);
        analyzer.execute(effectiveRuleSet);
        ReportHelper reportHelper = new ReportHelper(console);
        reportHelper.verifyConceptResults(reportWriter);
        reportHelper.verifyConstraintViolations(reportWriter);
        store.stop();
        return Continuation.INPUT_COMPLETE;
    }
View Full Code Here


     * @component
     */
    protected StoreProvider storeProvider;

    protected <T> T executeInTransaction(StoreOperation<T> operation) throws MojoExecutionException, MojoFailureException {
        final Store store = getStore();
        store.beginTransaction();
        try {
            return operation.run(store);
        } finally {
            store.commitTransaction();
        }
    }
View Full Code Here

     *
     * @param databaseDirectory The database directory to use.
     * @return The {@link Store} instance.
     */
    public Store getStore(final File databaseDirectory) {
        Store store = stores.get(databaseDirectory);
        if (store == null) {
            LOGGER.info("Opening store in directory '{}'.", databaseDirectory.getAbsolutePath());
            databaseDirectory.getParentFile().mkdirs();
            store = new EmbeddedGraphStore(databaseDirectory.getAbsolutePath());
            store.start();
            stores.put(databaseDirectory, store);
        }
        return store;
    }
View Full Code Here

            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
            persistence = unmarshaller.unmarshal(new StreamSource(item), Persistence.class).getValue();
        } catch (JAXBException e) {
            throw new IOException("Cannot read model descriptor.", e);
        }
        Store store = getStore();
        PersistenceDescriptor persistenceDescriptor = store.create(PersistenceDescriptor.class);
        persistenceDescriptor.setVersion(persistence.getVersion());
        // Create model units
        for (PersistenceUnit persistenceUnit : persistence.getPersistenceUnit()) {
            PersistenceUnitDescriptor persistenceUnitDescriptor = store.create(PersistenceUnitDescriptor.class);
            persistenceUnitDescriptor.setName(persistenceUnit.getName());
            PersistenceUnitTransactionType transactionType = persistenceUnit.getTransactionType();
            if (transactionType != null) {
                persistenceUnitDescriptor.setTransactionType(transactionType.name());
            }
            persistenceUnitDescriptor.setDescription(persistenceUnit.getDescription());
            persistenceUnitDescriptor.setJtaDataSource(persistenceUnit.getJtaDataSource());
            persistenceUnitDescriptor.setNonJtaDataSource(persistenceUnit.getNonJtaDataSource());
            persistenceUnitDescriptor.setProvider(persistenceUnit.getProvider());
            PersistenceUnitValidationModeType validationMode = persistenceUnit.getValidationMode();
            if (validationMode != null) {
                persistenceUnitDescriptor.setValidationMode(validationMode.name());
            }
            PersistenceUnitCachingType sharedCacheMode = persistenceUnit.getSharedCacheMode();
            if (sharedCacheMode != null) {
                persistenceUnitDescriptor.setSharedCacheMode(sharedCacheMode.name());
            }
            for (String clazz : persistenceUnit.getClazz()) {
                TypeDescriptor typeDescriptor = descriptorResolverFactory.getTypeDescriptorResolver().resolve(clazz);
                persistenceUnitDescriptor.getContains().add(typeDescriptor);
            }
            // Create persistence unit properties
            PersistenceUnit.Properties properties = persistenceUnit.getProperties();
            if (properties != null) {
                for (Property property : properties.getProperty()) {
                    PropertyDescriptor propertyDescriptor = store.create(PropertyDescriptor.class);
                    propertyDescriptor.setName(property.getName());
                    propertyDescriptor.setValue(property.getValue());
                    persistenceUnitDescriptor.getProperties().add(propertyDescriptor);
                }
            }
View Full Code Here

        return true;
    }

    @Override
    public Iterable<FileDescriptor> scan(MavenProject project, String path, Scope scope, Scanner scanner) throws IOException {
        Store store = getStore();
        store.beginTransaction();
        try {
            final ArtifactDescriptor artifact = resolveArtifact(project.getArtifact(), false, ArtifactDescriptor.class);
            for (File file : getPdeFiles(project)) {
                consume(scanner.scan(file, file.getPath(), CLASSPATH), new IterableConsumer.Consumer<FileDescriptor>() {
                    @Override
                    public void next(FileDescriptor fileDescriptor) {
                        artifact.addContains(fileDescriptor);
                    }
                });
            }
        } finally {
            store.commitTransaction();
        }
        return emptyList();
    }
View Full Code Here

    @Produces(MediaType.TEXT_PLAIN)
    @Consumes(MediaType.APPLICATION_JSON)
    @Path("/concept")
    public Response runConcept(String conceptId) {
        InMemoryReportWriter report;
        Store store = getStore();
        try {
            store.start(getScannerPluginRepository().getDescriptorTypes());
            report = analyze(store, Arrays.asList(conceptId), Collections.<String> emptyList(), Collections.<String> emptyList());

            int conceptResultSize = report.getConceptResults().size();

            if (conceptResultSize == 0) { // nothing modified
                return Response.status(Response.Status.NOT_MODIFIED).build();
            } else {
                return Response.status(Response.Status.OK).entity((Integer.toString(conceptResultSize))).build();
            }
        } catch (Exception e) {
            return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity((e.getMessage())).build();
        } finally {
            store.stop();
        }
    }
View Full Code Here

    @Override
    public final void execute() throws MojoExecutionException, MojoFailureException {
        Aggregator.execute(new Aggregator.AggregatedGoal() {
            public void execute(MavenProject baseProject, Set<MavenProject> projects) throws MojoExecutionException, MojoFailureException {
                List<Class<?>> descriptorTypes;
                Store store = getStore(baseProject);
                try {
                    descriptorTypes = getScannerPluginRepository(store, getPluginProperties(baseProject)).getDescriptorTypes();
                } catch (PluginRepositoryException e) {
                    throw new MojoExecutionException("Cannot get descriptor mappers.", e);
                }
                try {
                    store.start(descriptorTypes);
                    AbstractAnalysisMojo.this.aggregate(baseProject, projects, store);
                } finally {
                    store.stop();
                }
            }
        }, currentProject, reactorProjects);
    }
View Full Code Here

    public StoreRepository() {
        LOGGER.info("Initializing store repository.");
    }

    public Store getStore(File directory, boolean reset) {
        Store store = stores.get(directory);
        if (store == null) {
            LOGGER.info("Opening store in directory '" + directory.getAbsolutePath() + "'");
            directory.getParentFile().mkdirs();
            store = new EmbeddedGraphStore(directory.getAbsolutePath());
            if (reset) {
                // reset the store if the current project is the base project
                // (i.e. where the rules are located).
                store.start(Collections.<Class<?>> emptyList());
                store.reset();
                store.stop();
            }
            stores.put(directory, store);
        }
        return store;
    }
View Full Code Here

TOP

Related Classes of com.buschmais.jqassistant.core.store.api.Store

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.