Search in sources :

Example 1 with LockModeType

use of javax.persistence.LockModeType in project dwoss by gg-net.

the class DesktopBundleViewTryout method tryoutView.

@Test
public void tryoutView() throws InterruptedException {
    final ProductSpec spec = new SpecGenerator().makeSpec();
    DesktopBundleView view = new DesktopBundleView(new Mandators() {

        @Override
        public Mandator loadMandator() {
            return Mandator.builder().defaultMailSignature(null).smtpConfiguration(null).mailTemplateLocation(null).company(CompanyGen.makeCompany()).dossierPrefix("DW").documentIntermix(null).documentIdentifierGeneratorConfigurations(new EnumMap<>(DocumentType.class)).build();
        }

        @Override
        public DefaultCustomerSalesdata loadSalesdata() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("loadSalesdata - Not supported yet.");
        }

        @Override
        public ReceiptCustomers loadReceiptCustomers() {
            return ReceiptCustomers.builder().build();
        }

        @Override
        public SpecialSystemCustomers loadSystemCustomers() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("loadSystemCustomers - Not supported yet.");
        }

        @Override
        public Contractors loadContractors() {
            return new Contractors(EnumSet.of(TradeName.ALSO, TradeName.ACER), EnumSet.of(TradeName.ACER));
        }

        @Override
        public PostLedger loadPostLedger() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("loadPostLedger - Not supported yet.");
        }

        @Override
        public ShippingTerms loadShippingTerms() {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("loadShippingTerms - Not supported yet.");
        }
    }, new SpecAgent() {

        @Override
        public ProductSpec findProductSpecByPartNoEager(String partNo) {
            if (partNo == null)
                return null;
            if (partNo.startsWith("X"))
                return null;
            spec.setPartNo(partNo);
            return spec;
        }

        // <editor-fold defaultstate="collapsed" desc="Unneeded Methods">
        @Override
        public <T> long count(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAll(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }
    }, new ProductProcessorStub(), TradeName.ACER, TradeName.ACER, ProductGroup.DESKTOP, ProductGroup.MONITOR);
    view.setSpec(new DesktopBundle());
    OkCancelDialog<DesktopBundleView> dialog = new OkCancelDialog<>("BundleView", view);
    dialog.setVisible(true);
    dialog.dispose();
}
Also used : ProductProcessorStub(eu.ggnet.dwoss.receipt.stub.ProductProcessorStub) SpecAgent(eu.ggnet.dwoss.spec.ee.SpecAgent) SpecGenerator(eu.ggnet.dwoss.spec.ee.assist.gen.SpecGenerator) OkCancelDialog(eu.ggnet.dwoss.util.OkCancelDialog) ProductSpec(eu.ggnet.dwoss.spec.ee.entity.ProductSpec) DesktopBundle(eu.ggnet.dwoss.spec.ee.entity.DesktopBundle) DesktopBundleView(eu.ggnet.dwoss.receipt.product.DesktopBundleView) Mandators(eu.ggnet.dwoss.mandator.Mandators) LockModeType(javax.persistence.LockModeType) Test(org.junit.Test)

Example 2 with LockModeType

use of javax.persistence.LockModeType in project dwoss by gg-net.

the class SimpleReportLineTryout method main.

public static void main(String[] args) {
    ReportAgent rastub = new ReportAgent() {

        List<eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine> all = Arrays.asList(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ACER).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.DELL).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(10).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.HP).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(23).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.AMAZON).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.EMACHINES).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.FUJITSU).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ONESELF).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.LENOVO).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").partNo("AA.BBBBB.CC").uniqueUnitId(1000).reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.FUJITSU).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.SAMSUNG).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.SAMSUNG).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.AMAZON).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build(), eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.builder().amount(1).contractor(TradeName.ALSO).contractorReferencePrice(100).documentType(DocumentType.INVOICE).positionType(PositionType.UNIT).price(50).productName("ABCDEFG").purchasePrice(40).refurbishId("1234567").reportingDate(new Date()).build());

        @Override
        public <T> List<T> findAll(Class<T> entityClass) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class))
                return (List<T>) all;
            return Collections.EMPTY_LIST;
        }

        @Override
        public <T> List<T> findAll(Class<T> entityClass, int start, int amount) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class)) {
                if (start > all.size())
                    return Collections.EMPTY_LIST;
                if (start < 0)
                    start = 0;
                if (amount + start > all.size())
                    amount = all.size() - start;
                return (List<T>) all.subList(start, amount + start);
            }
            return Collections.EMPTY_LIST;
        }

        @Override
        public List<eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine> findSimple(SearchParameter search, int firstResult, int maxResults) {
            return findAll(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class, firstResult, maxResults);
        }

        @Override
        public long count(SearchParameter search) {
            return all.size();
        }

        @Override
        public <T> long count(Class<T> entityClass) {
            if (entityClass.equals(eu.ggnet.dwoss.report.ee.entity.partial.SimpleReportLine.class))
                return all.size();
            return 0;
        }

        // <editor-fold defaultstate="collapsed" desc="Unused Methods">
        @Override
        public Report store(Report report, Collection<Storeable> storeables) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findAllReportLinesReverse(int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public Set<ReportLine> attachDanglingComplaints(TradeName type, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> List<T> findAllEager(Class<T> entityClass, int start, int amount) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findById(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public <T> T findByIdEager(Class<T> entityClass, Object id, LockModeType lockModeType) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> find(SearchParameter search, int firstResult, int maxResults) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult findReportResult(long reportId) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public List<ReportLine> findReportLinesByDocumentType(DocumentType type, Date from, Date till) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public ViewReportResult prepareReport(ReportParameter p, boolean loadUnreported) {
            // To change body of generated methods, choose Tools | Templates.
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public boolean updateReportLineComment(int optLock, long reportId, String comment) {
            System.out.println("Line = " + reportId + " adding comment " + comment);
            return true;
        }

        @Override
        public Reply<String> updateReportName(Report.OptimisticKey key, String name) {
            System.out.println("Report = " + key + " changing name = " + name);
            return Reply.success(name);
        }
    };
    Dl.remote().add(ReportAgent.class, rastub);
    Ui.exec(() -> {
        UiCore.startSwing(() -> new JLabel("Main Applikation"));
        Ui.build().fx().show(() -> {
            RawReportView srl = new RawReportView();
            srl.load(new SearchParameter());
            return srl;
        });
    });
}
Also used : ReportLine(eu.ggnet.dwoss.report.ee.entity.ReportLine) ReportParameter(eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter) ReportAgent(eu.ggnet.dwoss.report.ee.ReportAgent) SearchParameter(eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter) Report(eu.ggnet.dwoss.report.ee.entity.Report) RawReportView(eu.ggnet.dwoss.report.ui.RawReportView) JLabel(javax.swing.JLabel) LockModeType(javax.persistence.LockModeType)

Example 3 with LockModeType

use of javax.persistence.LockModeType in project wildfly by wildfly.

the class AbstractEntityManager method getLockMode.

public LockModeType getLockMode(Object entity) {
    long start = 0;
    if (isTraceEnabled)
        start = System.currentTimeMillis();
    LockModeType result = null;
    try {
        result = getEntityManager().getLockMode(entity);
    } finally {
        if (isTraceEnabled) {
            long elapsed = System.currentTimeMillis() - start;
            ROOT_LOGGER.tracef("getLockMode entityClass '%s', lockMode '%s'  took %dms", entity.getClass().getName(), getLockModeAsString(result), elapsed);
        }
    }
    return result;
}
Also used : LockModeType(javax.persistence.LockModeType)

Example 4 with LockModeType

use of javax.persistence.LockModeType in project hibernate-orm by hibernate.

the class QueryHintDefinition method determineLockOptions.

public LockOptions determineLockOptions(NamedQuery namedQueryAnnotation) {
    LockModeType lockModeType = namedQueryAnnotation.lockMode();
    Integer lockTimeoutHint = getInteger(namedQueryAnnotation.name(), "javax.persistence.lock.timeout");
    Boolean followOnLocking = getBoolean(namedQueryAnnotation.name(), QueryHints.FOLLOW_ON_LOCKING);
    return determineLockOptions(lockModeType, lockTimeoutHint, followOnLocking);
}
Also used : LockModeType(javax.persistence.LockModeType)

Example 5 with LockModeType

use of javax.persistence.LockModeType in project deltaspike by apache.

the class CdiQueryInvocationContext method applyRestrictions.

public Query applyRestrictions(Query query) {
    Parameters params = getParams();
    Method method = getMethod();
    if (params.hasSizeRestriction()) {
        query.setMaxResults(params.getSizeRestriciton());
    }
    if (params.hasFirstResult()) {
        query.setFirstResult(params.getFirstResult());
    }
    LockModeType lockMode = extractLockMode();
    if (lockMode != null) {
        query.setLockMode(lockMode);
    }
    QueryHint[] hints = extractQueryHints();
    if (hints != null) {
        for (QueryHint hint : hints) {
            query.setHint(hint.name(), hint.value());
        }
    }
    applyEntityGraph(query, method);
    query = applyJpaQueryPostProcessors(query);
    return query;
}
Also used : Parameters(org.apache.deltaspike.data.impl.param.Parameters) QueryHint(javax.persistence.QueryHint) LockModeType(javax.persistence.LockModeType) Method(java.lang.reflect.Method)

Aggregations

LockModeType (javax.persistence.LockModeType)11 Test (org.junit.Test)4 StockAgent (eu.ggnet.dwoss.stock.ee.StockAgent)3 Stock (eu.ggnet.dwoss.stock.ee.entity.Stock)3 StockTransaction (eu.ggnet.dwoss.stock.ee.entity.StockTransaction)3 StockTransactionStatusType (eu.ggnet.dwoss.stock.ee.entity.StockTransactionStatusType)3 StockTransactionType (eu.ggnet.dwoss.stock.ee.entity.StockTransactionType)3 StockUnit (eu.ggnet.dwoss.stock.ee.entity.StockUnit)3 Dimension (java.awt.Dimension)3 Mandators (eu.ggnet.dwoss.mandator.Mandators)2 ProductProcessorStub (eu.ggnet.dwoss.receipt.stub.ProductProcessorStub)2 ReportAgent (eu.ggnet.dwoss.report.ee.ReportAgent)2 ReportParameter (eu.ggnet.dwoss.report.ee.ReportAgent.ReportParameter)2 SearchParameter (eu.ggnet.dwoss.report.ee.ReportAgent.SearchParameter)2 Report (eu.ggnet.dwoss.report.ee.entity.Report)2 ReportLine (eu.ggnet.dwoss.report.ee.entity.ReportLine)2 DocumentType (eu.ggnet.dwoss.rules.DocumentType)2 TradeName (eu.ggnet.dwoss.rules.TradeName)2 SpecAgent (eu.ggnet.dwoss.spec.ee.SpecAgent)2 SpecGenerator (eu.ggnet.dwoss.spec.ee.assist.gen.SpecGenerator)2