Search in sources :

Example 41 with ObjectFactory

use of net.opengis.cat.csw._3.ObjectFactory in project geo-platform by geosdi.

the class QueryRestrictionsBuilderTest method createFilterType.

/**
 * @return {@link FilterType}
 */
private FilterType createFilterType() {
    FilterType filter = new FilterType();
    BBox bbox = new BBox(14.131237640976908, 36.56356461583572, 15.821758881211283, 37.143760728459014);
    BBOXType bBoxType = new BBOXType();
    PropertyNameType propertyNameType = new PropertyNameType();
    propertyNameType.setContent(Arrays.asList("the_geom"));
    bBoxType.setPropertyName(propertyNameType);
    EnvelopeType envelope = new EnvelopeType();
    DirectPositionType lower = new DirectPositionType();
    lower.setValue(asList(bbox.getMinX(), bbox.getMinY()));
    envelope.setLowerCorner(lower);
    DirectPositionType upper = new DirectPositionType();
    upper.setValue(asList(bbox.getMaxX(), bbox.getMaxY()));
    envelope.setUpperCorner(upper);
    envelope.setSrsName("EPSG:4326");
    bBoxType.setEnvelope(new ObjectFactory().createEnvelope(envelope));
    filter.setSpatialOps(new org.geosdi.geoplatform.xml.filter.v110.ObjectFactory().createBBOX(bBoxType));
    return filter;
}
Also used : FilterType(org.geosdi.geoplatform.xml.filter.v110.FilterType) EnvelopeType(org.geosdi.geoplatform.xml.gml.v311.EnvelopeType) BBOXType(org.geosdi.geoplatform.xml.filter.v110.BBOXType) DirectPositionType(org.geosdi.geoplatform.xml.gml.v311.DirectPositionType) ObjectFactory(org.geosdi.geoplatform.xml.gml.v311.ObjectFactory) BBox(org.geosdi.geoplatform.gui.shared.bean.BBox) PropertyNameType(org.geosdi.geoplatform.xml.filter.v110.PropertyNameType)

Example 42 with ObjectFactory

use of net.opengis.cat.csw._3.ObjectFactory in project sigla-main by consiglionazionaledellericerche.

the class DocAmmFatturazioneElettronicaComponent method preparaFattura.

public FatturaElettronicaType preparaFattura(UserContext userContext, Fattura_attivaBulk fattura) throws ComponentException {
    try {
        ObjectFactory factory = new ObjectFactory();
        FatturaElettronicaType fatturaType = factory.createFatturaElettronicaType();
        fatturaType.setSistemaEmittente(Utility.APPLICATION_TITLE.substring(0, 5));
        fatturaType.setVersione(fattura.getCodiceUnivocoUfficioIpa() == null ? FormatoTrasmissioneType.FPR_12 : FormatoTrasmissioneType.FPA_12);
        FatturaElettronicaHeaderType fatturaHeaderType = factory.createFatturaElettronicaHeaderType();
        TerzoBulk terzoCnr = ((TerzoHome) getHome(userContext, TerzoBulk.class)).findTerzoEnte();
        TerzoBulk cliente = fattura.getCliente();
        TerzoBulk terzoUo = fattura.getTerzo_uo();
        if (terzoCnr != null) {
            DatiTrasmissioneType datiTrasmissione = factory.createDatiTrasmissioneType();
            datiTrasmissione.setIdTrasmittente(impostaIdTrasmittente(userContext, factory, terzoCnr));
            datiTrasmissione.setProgressivoInvio(fattura.getEsercizio().toString() + Utility.lpad(fattura.getProgrUnivocoAnno().toString(), 6, '0'));
            if (fattura.getCodiceUnivocoUfficioIpa() != null) {
                datiTrasmissione.setCodiceDestinatario(fattura.getCodiceUnivocoUfficioIpa());
            } else {
                if (fattura.getCodiceDestinatarioFatt() != null) {
                    datiTrasmissione.setCodiceDestinatario(fattura.getCodiceDestinatarioFatt());
                } else {
                    if (fattura.isFatturaEstera()) {
                        datiTrasmissione.setCodiceDestinatario(CODICE_DESTINATARIO_ESTERO);
                    } else {
                        datiTrasmissione.setCodiceDestinatario(CODICE_DESTINATARIO_CON_PEC_O_NON_REGISTRATO);
                    }
                    datiTrasmissione.setPECDestinatario(fattura.getPecFatturaElettronica());
                }
            }
            ContattiTrasmittenteType contattiTrasmittenteType = factory.createContattiTrasmittenteType();
            String eMailReferente = Utility.createConfigurazioneCnrComponentSession().getVal01(userContext, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FATTURAZIONE_ELETTRONICA, Configurazione_cnrBulk.SK_MAIL_REFERENTE_TECNICO);
            contattiTrasmittenteType.setEmail(eMailReferente);
            String telefonoReferente = Utility.createConfigurazioneCnrComponentSession().getVal01(userContext, it.cnr.contab.utenze00.bp.CNRUserContext.getEsercizio(userContext), null, Configurazione_cnrBulk.PK_FATTURAZIONE_ELETTRONICA, Configurazione_cnrBulk.SK_TELEFONO_REFERENTE_TECNICO);
            contattiTrasmittenteType.setTelefono(telefonoReferente);
            datiTrasmissione.setContattiTrasmittente(contattiTrasmittenteType);
            datiTrasmissione.setFormatoTrasmissione(fattura.getCodiceUnivocoUfficioIpa() == null ? FormatoTrasmissioneType.FPR_12 : FormatoTrasmissioneType.FPA_12);
            fatturaHeaderType.setDatiTrasmissione(datiTrasmissione);
            CedentePrestatoreType cedentePrestatoreType = factory.createCedentePrestatoreType();
            DatiAnagraficiCedenteType anagraficiCedenteType = factory.createDatiAnagraficiCedenteType();
            if (terzoCnr.getAnagrafico() == null || terzoCnr.getAnagrafico().getPartita_iva() == null)
                throw new ApplicationException("Impossibile Procedere! Manca la Partita Iva per il codice Anagrafica: " + terzoCnr.getCd_anag() + " del terzo: " + terzoCnr.getCd_terzo());
            anagraficiCedenteType.setIdFiscaleIVA(impostaIdFiscale(userContext, factory, terzoCnr, null));
            if (terzoCnr.getAnagrafico().getCodice_fiscale() == null)
                throw new ApplicationException("Impossibile Procedere! Manca il Codice Fiscale per il codice Anagrafica: " + terzoCnr.getCd_anag() + " del terzo: " + terzoCnr.getCd_terzo());
            anagraficiCedenteType.setCodiceFiscale(terzoCnr.getAnagrafico().getCodice_fiscale());
            anagraficiCedenteType.setAnagrafica(impostaAnagrafica(factory, terzoCnr));
            anagraficiCedenteType.setRegimeFiscale(RegimeFiscaleType.RF_01);
            cedentePrestatoreType.setDatiAnagrafici(anagraficiCedenteType);
            cedentePrestatoreType.setSede(impostaIndirizzo(userContext, factory, terzoUo));
            // TODO: Per il momento non lo gestiamo. Il dato non è obbligatorio.
            // ContattiType contattiCedente = factory.createContattiType();
            // contattiCedente.setEmail(value);
            // cedentePrestatoreType.setContatti(contattiCedente);
            fatturaHeaderType.setCedentePrestatore(cedentePrestatoreType);
            CessionarioCommittenteType clienteType = factory.createCessionarioCommittenteType();
            DatiAnagraficiCessionarioType datiAnagraficiClienteType = factory.createDatiAnagraficiCessionarioType();
            datiAnagraficiClienteType.setAnagrafica(impostaAnagrafica(factory, cliente));
            if (fattura.getFl_intra_ue() && cliente.getAnagrafico().isPersonaGiuridica() && cliente.getCodiceUnivocoUfficioIpa() == null && cliente.getAnagrafico().getPartita_iva() == null) {
                throw new ApplicationException("Impossibile Procedere! E' necessario indicare la partita IVA");
            }
            if ((!fattura.isFatturaEstera() || !cliente.getAnagrafico().isPersonaGiuridica()) && (fattura.getCodice_fiscale() == null && !cliente.getAnagrafico().isGruppoIVA())) {
                throw new ApplicationException("Impossibile Procedere! Manca il Codice Fiscale per la Fattura: " + fattura.getEsercizio() + "-" + fattura.getPg_fattura_attiva());
            }
            if (!fattura.isFatturaEstera()) {
                datiAnagraficiClienteType.setCodiceFiscale(fattura.getCodice_fiscale());
            }
            if (cliente.getAnagrafico() != null && cliente.getAnagrafico().getPartita_iva() != null && (!cliente.getAnagrafico().isEntePubblico() || cliente.getAnagrafico().isPartitaIvaVerificata() || (fattura.getCodice_fiscale() != null && cliente.getAnagrafico().getPartita_iva().compareTo(fattura.getCodice_fiscale()) != 0))) {
                datiAnagraficiClienteType.setIdFiscaleIVA(impostaIdFiscale(userContext, factory, cliente, fattura));
            } else if (!StringUtils.hasLength(datiAnagraficiClienteType.getCodiceFiscale())) {
                datiAnagraficiClienteType.setIdFiscaleIVA(impostaIdFiscale(userContext, factory, cliente, fattura));
            } else if (fattura.isFatturaEstera() && cliente.getAnagrafico().isPersonaFisica()) {
                IdFiscaleType idFiscale = factory.createIdFiscaleType();
                idFiscale.setIdCodice("99999999999");
                idFiscale.setIdPaese(impostaCodicePaese(userContext, cliente));
                datiAnagraficiClienteType.setIdFiscaleIVA(idFiscale);
            }
            if (!StringUtils.hasLength(datiAnagraficiClienteType.getCodiceFiscale()) && !StringUtils.hasLength(datiAnagraficiClienteType.getIdFiscaleIVA().getIdCodice())) {
                datiAnagraficiClienteType.getIdFiscaleIVA().setIdCodice("99999999999");
            }
            clienteType.setDatiAnagrafici(datiAnagraficiClienteType);
            clienteType.setSede(impostaIndirizzo(userContext, factory, cliente, fattura));
            fatturaHeaderType.setCessionarioCommittente(clienteType);
            fatturaType.setFatturaElettronicaHeader(fatturaHeaderType);
            FatturaElettronicaBodyType fatturaBodyType = factory.createFatturaElettronicaBodyType();
            DatiGeneraliType datiGenerali = factory.createDatiGeneraliType();
            DatiGeneraliDocumentoType datiGeneraliDocumento = factory.createDatiGeneraliDocumentoType();
            datiGeneraliDocumento.setTipoDocumento(tipoDocumento.get(fattura.getTi_fattura()));
            datiGeneraliDocumento.setDivisa("EUR");
            datiGeneraliDocumento.setData(convertDateToXmlGregorian(it.cnr.jada.util.ejb.EJBCommonServices.getServerDate()));
            datiGeneraliDocumento.setNumero(fattura.recuperoIdFatturaAsString());
            List list = (List) ((FatturaAttivaSingolaComponentSession) it.cnr.jada.util.ejb.EJBCommonServices.createEJB("CNRDOCAMM00_EJB_FatturaAttivaSingolaComponentSession", FatturaAttivaSingolaComponentSession.class)).findDettagli(userContext, fattura);
            if (list != null) {
                BulkList dettaglio = new BulkList(list);
                if (dettaglio == null || dettaglio.isEmpty()) {
                    throw new ApplicationException("Impossibile Procedere! La Fattura: " + fattura.getEsercizio() + "-" + fattura.getPg_fattura_attiva() + " non ha dettagli");
                }
                Boolean esisteBollo = gestioneBollo(userContext, factory, datiGeneraliDocumento, fattura, dettaglio);
                datiGeneraliDocumento.setImportoTotaleDocumento(fattura.getIm_totale_fattura().setScale(2));
                String descrizione = "";
                if (fattura.getDs_fattura_attiva() != null) {
                    descrizione = fattura.getDs_fattura_attiva();
                }
                List<String> listaCausali = new ArrayList<String>();
                if (fattura.getRiferimento_ordine() != null && fattura.getDt_ordine() == null) {
                    if (!descrizione.equals("")) {
                        descrizione += "  ";
                    }
                    descrizione += "Riferimento ordine:" + fattura.getRiferimento_ordine();
                }
                int lunghezzaStringaCausale = 200;
                int numeroCaratteriFinali = 0;
                for (int i = 0; i <= descrizione.length() / lunghezzaStringaCausale; i++) {
                    int numeroCaratteri = i * lunghezzaStringaCausale;
                    int numeroCaratteriOccorrenti = (numeroCaratteri + lunghezzaStringaCausale);
                    if (numeroCaratteriOccorrenti > descrizione.length()) {
                        numeroCaratteriFinali = numeroCaratteri + (descrizione.length() - numeroCaratteri);
                    } else {
                        numeroCaratteriFinali = numeroCaratteri + lunghezzaStringaCausale;
                    }
                    if (numeroCaratteri < numeroCaratteriFinali) {
                        String causale = descrizione.substring(numeroCaratteri, numeroCaratteriFinali);
                        listaCausali.add(RemoveAccent.convert(causale));
                    }
                }
                datiGeneraliDocumento.getCausale().addAll(listaCausali);
                datiGenerali.setDatiGeneraliDocumento(datiGeneraliDocumento);
                DatiBeniServiziType datiBeniServizi = factory.createDatiBeniServiziType();
                List<DettaglioLineeType> listaDettagli = new ArrayList<DettaglioLineeType>();
                List<RiepilogoPerAliquotaIVA> listaRiepilogo = new ArrayList<DocAmmFatturazioneElettronicaComponent.RiepilogoPerAliquotaIVA>();
                HashMap<ContrattoBulk, List<Integer>> mappaContratti = new HashMap<ContrattoBulk, List<Integer>>();
                HashMap<Fattura_attivaBulk, List<Integer>> dettagliNoteSenzaContratto = new HashMap<Fattura_attivaBulk, List<Integer>>();
                HashMap<Fattura_attivaBulk, HashMap<ContrattoBulk, List<Integer>>> mappaDocumentiCollegati = new HashMap<Fattura_attivaBulk, HashMap<ContrattoBulk, List<Integer>>>();
                List<Integer> listaTutteLinee = new ArrayList<>();
                for (Iterator<Fattura_attiva_rigaBulk> i = dettaglio.iterator(); i.hasNext(); ) {
                    Fattura_attiva_rigaBulk riga = (Fattura_attiva_rigaBulk) i.next();
                    listaTutteLinee.add(riga.getProgressivo_riga().intValue());
                    DettaglioLineeType rigaFattura = factory.createDettaglioLineeType();
                    rigaFattura.setNumeroLinea(riga.getProgressivo_riga().intValue());
                    if (riga.getDs_riga_fattura() != null) {
                        rigaFattura.setDescrizione(RemoveAccent.convert(riga.getDs_riga_fattura().replaceAll("\\u20AC", "E")));
                    } else {
                        rigaFattura.setDescrizione("Descrizione");
                    }
                    rigaFattura.setQuantita(riga.getQuantita().setScale(2));
                    if (riga.getTariffario() != null && riga.getTariffario().getCd_tariffario() != null) {
                        if (riga.getTariffario().getUnita_misura() == null)
                            riga.setTariffario((TariffarioBulk) findByPrimaryKey(userContext, riga.getTariffario()));
                        rigaFattura.setUnitaMisura(riga.getTariffario().getUnita_misura());
                    }
                    rigaFattura.setDataInizioPeriodo(convertDateToXmlGregorian(riga.getDt_da_competenza_coge()));
                    rigaFattura.setDataFinePeriodo(convertDateToXmlGregorian(riga.getDt_a_competenza_coge()));
                    rigaFattura.setPrezzoUnitario(riga.getPrezzo_unitario().setScale(2));
                    rigaFattura.setPrezzoTotale(rigaFattura.getPrezzoUnitario().multiply(rigaFattura.getQuantita()).setScale(2));
                    if (riga.getVoce_iva() != null && riga.getVoce_iva().getCd_voce_iva() != null && riga.getVoce_iva().getPercentuale() == null)
                        riga.setVoce_iva((Voce_ivaBulk) findByPrimaryKey(userContext, riga.getVoce_iva()));
                    rigaFattura.setAliquotaIVA(Utility.nvl(riga.getVoce_iva().getPercentuale()).setScale(2));
                    rigaFattura.setNatura(impostaDatiNatura(riga.getVoce_iva().getNaturaOperNonImpSdi()));
                    listaDettagli.add(rigaFattura);
                    if (fattura.getTi_fattura().equals(Fattura_attivaBulk.TIPO_NOTA_DI_CREDITO)) {
                        impostaDatiPerNoteCredito(userContext, mappaDocumentiCollegati, riga, dettagliNoteSenzaContratto);
                    }
                    preparaDatiContratto(userContext, mappaContratti, riga);
                    impostaDatiPerRiepilogoDatiIva(listaRiepilogo, riga);
                }
                datiBeniServizi.getDettaglioLinee().addAll(listaDettagli);
                impostaDatiContratto(factory, datiGenerali, mappaContratti);
                impostaDatiDocumentiCollegati(factory, datiGenerali, mappaDocumentiCollegati, dettagliNoteSenzaContratto);
                if (!fattura.isFatturaEstera() && fattura.getRiferimento_ordine() != null && fattura.getDt_ordine() != null) {
                    DatiDocumentiCorrelatiType datiOrdineAcquisto = factory.createDatiDocumentiCorrelatiType();
                    datiOrdineAcquisto.getRiferimentoNumeroLinea().addAll(listaTutteLinee);
                    datiOrdineAcquisto.setData(convertDateToXmlGregorian(fattura.getDt_ordine()));
                    datiOrdineAcquisto.setIdDocumento(substring(fattura.getRiferimento_ordine(), 20));
                    String soggettoOrdine = null;
                    if (!fattura.getFl_ordine_elettronico()) {
                        soggettoOrdine = "#NO#";
                    } else {
                        if (fattura.getCodiceUnivocoUfficioIpa() != null) {
                            soggettoOrdine = "#0201:" + fattura.getCodiceUnivocoUfficioIpa() + "#";
                        } else {
                            if (fattura.getPartita_iva() != null) {
                                soggettoOrdine = "#9906:";
                            } else {
                                soggettoOrdine = "#9907:";
                            }
                            if (fattura.getCodiceDestinatarioFatt() != null) {
                                soggettoOrdine += fattura.getCodiceDestinatarioFatt();
                            } else if (fattura.getPecFatturaElettronica() != null) {
                                soggettoOrdine += fattura.getPecFatturaElettronica();
                            } else {
                                soggettoOrdine += datiTrasmissione.getCodiceDestinatario();
                            }
                            soggettoOrdine += "#";
                        }
                    }
                    datiOrdineAcquisto.setCodiceCommessaConvenzione(soggettoOrdine);
                    datiGenerali.getDatiOrdineAcquisto().add(datiOrdineAcquisto);
                }
                fatturaBodyType.setDatiGenerali(datiGenerali);
                List<DatiRiepilogoType> listaRiepilogoType = new ArrayList<DatiRiepilogoType>();
                for (Iterator<RiepilogoPerAliquotaIVA> i = listaRiepilogo.iterator(); i.hasNext(); ) {
                    RiepilogoPerAliquotaIVA riepilogo = (RiepilogoPerAliquotaIVA) i.next();
                    DatiRiepilogoType datiRiepilogo = factory.createDatiRiepilogoType();
                    datiRiepilogo.setAliquotaIVA(riepilogo.getAliquota());
                    if (fattura.getFl_liquidazione_differita()) {
                        datiRiepilogo.setEsigibilitaIVA(fattura.getEsercizio() > 2014 ? EsigibilitaIVAType.S : EsigibilitaIVAType.D);
                    } else {
                        datiRiepilogo.setEsigibilitaIVA(EsigibilitaIVAType.I);
                    }
                    datiRiepilogo.setImponibileImporto(riepilogo.getImponibile().setScale(2));
                    datiRiepilogo.setImposta(riepilogo.getImposta().setScale(2));
                    impostaDatiNonImponibile(fattura, riepilogo, datiRiepilogo);
                    listaRiepilogoType.add(datiRiepilogo);
                }
                datiBeniServizi.getDatiRiepilogo().addAll(listaRiepilogoType);
                fatturaBodyType.setDatiBeniServizi(datiBeniServizi);
                DatiPagamentoType datiPagamento = factory.createDatiPagamentoType();
                datiPagamento.setCondizioniPagamento(CondizioniPagamentoType.TP_02);
                List<DettaglioPagamentoType> listaDettagliPagamento = new ArrayList<DettaglioPagamentoType>();
                if (fattura.getTi_fattura().equals(Fattura_attivaBulk.TIPO_NOTA_DI_CREDITO)) {
                    for (Iterator<Fattura_attivaBulk> y = mappaDocumentiCollegati.keySet().iterator(); y.hasNext(); ) {
                        Fattura_attivaBulk fatturaCollegata = y.next();
                        listaDettagliPagamento.add(impostaDatiPagamento(userContext, terzoCnr, factory, fatturaCollegata));
                    }
                } else {
                    DettaglioPagamentoType dettaglioPagamento = impostaDatiPagamento(userContext, terzoCnr, factory, fattura);
                    dettaglioPagamento.setCodicePagamento(fattura.recuperoIdFatturaAsString());
                    listaDettagliPagamento.add(dettaglioPagamento);
                }
                datiPagamento.getDettaglioPagamento().addAll(listaDettagliPagamento);
                List<DatiPagamentoType> listaDatiPagamento = new ArrayList<DatiPagamentoType>();
                listaDatiPagamento.add(datiPagamento);
                fatturaBodyType.getDatiPagamento().addAll(listaDatiPagamento);
                List<FatturaElettronicaBodyType> listaFattureBody = new ArrayList<FatturaElettronicaBodyType>();
                listaFattureBody.add(fatturaBodyType);
                fatturaType.getFatturaElettronicaBody().addAll(listaFattureBody);
            }
        }
        return fatturaType;
    } catch (Exception e) {
        throw handleException(e);
    }
}
Also used : DatiBeniServiziType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiBeniServiziType) CessionarioCommittenteType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.CessionarioCommittenteType) TariffarioBulk(it.cnr.contab.docamm00.tabrif.bulk.TariffarioBulk) ObjectFactory(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.ObjectFactory) TerzoBulk(it.cnr.contab.anagraf00.core.bulk.TerzoBulk) BulkList(it.cnr.jada.bulk.BulkList) DettaglioPagamentoType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DettaglioPagamentoType) DatiGeneraliType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiGeneraliType) ContrattoBulk(it.cnr.contab.config00.contratto.bulk.ContrattoBulk) DatiDocumentiCorrelatiType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiDocumentiCorrelatiType) DatiPagamentoType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiPagamentoType) DatiAnagraficiCessionarioType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiAnagraficiCessionarioType) DatiRiepilogoType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiRiepilogoType) ContattiTrasmittenteType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.ContattiTrasmittenteType) DatiTrasmissioneType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiTrasmissioneType) TerzoHome(it.cnr.contab.anagraf00.core.bulk.TerzoHome) Voce_ivaBulk(it.cnr.contab.docamm00.tabrif.bulk.Voce_ivaBulk) FatturaElettronicaType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.FatturaElettronicaType) DatiAnagraficiCedenteType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiAnagraficiCedenteType) BulkList(it.cnr.jada.bulk.BulkList) DettaglioLineeType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DettaglioLineeType) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) RemoteException(java.rmi.RemoteException) EJBException(javax.ejb.EJBException) ApplicationException(it.cnr.jada.comp.ApplicationException) PersistencyException(it.cnr.jada.persistency.PersistencyException) IOException(java.io.IOException) ComponentException(it.cnr.jada.comp.ComponentException) CedentePrestatoreType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.CedentePrestatoreType) ApplicationException(it.cnr.jada.comp.ApplicationException) DatiGeneraliDocumentoType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.DatiGeneraliDocumentoType) IdFiscaleType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.IdFiscaleType) FatturaElettronicaHeaderType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.FatturaElettronicaHeaderType) FatturaElettronicaBodyType(it.gov.agenziaentrate.ivaservizi.docs.xsd.fatture.v1.FatturaElettronicaBodyType)

Example 43 with ObjectFactory

use of net.opengis.cat.csw._3.ObjectFactory in project axelor-open-suite by axelor.

the class BankOrderFile00100102Service method generateFile.

/**
 * Method to create an XML file for SEPA transfer pain.001.001.02
 *
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws JAXBException
 * @throws IOException
 */
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    ObjectFactory factory = new ObjectFactory();
    ServiceLevel2Choice svcLvl = factory.createServiceLevel2Choice();
    svcLvl.setCd(ServiceLevel1Code.SEPA);
    PaymentTypeInformation1 pmtTpInf = factory.createPaymentTypeInformation1();
    pmtTpInf.setSvcLvl(svcLvl);
    // Payer
    PartyIdentification8 dbtr = factory.createPartyIdentification8();
    dbtr.setNm(senderBankDetails.getOwnerName());
    // IBAN
    AccountIdentification3Choice iban = factory.createAccountIdentification3Choice();
    iban.setIBAN(senderBankDetails.getIban());
    CashAccount7 dbtrAcct = factory.createCashAccount7();
    dbtrAcct.setId(iban);
    // BIC
    FinancialInstitutionIdentification5Choice finInstnId = factory.createFinancialInstitutionIdentification5Choice();
    fillBic(finInstnId, senderBankDetails.getBank());
    BranchAndFinancialInstitutionIdentification3 dbtrAgt = factory.createBranchAndFinancialInstitutionIdentification3();
    dbtrAgt.setFinInstnId(finInstnId);
    PaymentInstructionInformation1 pmtInf = factory.createPaymentInstructionInformation1();
    pmtInf.setPmtInfId(bankOrderSeq);
    pmtInf.setPmtMtd(PaymentMethod3Code.TRF);
    pmtInf.setPmtTpInf(pmtTpInf);
    /**
     * RequestedExecutionDate Definition : Date at which the initiating party asks the Debtor's Bank
     * to process the payment. This is the date on which the debtor's account(s) is (are) to be
     * debited. XML Tag : <ReqdExctnDt> Occurrences : [1..1] Format : YYYY-MM-DD Rules : date is
     * limited to maximum one year in the future.
     */
    pmtInf.setReqdExctnDt(datatypeFactory.newXMLGregorianCalendar(bankOrderDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
    pmtInf.setDbtr(dbtr);
    pmtInf.setDbtrAcct(dbtrAcct);
    pmtInf.setDbtrAgt(dbtrAgt);
    CreditTransferTransactionInformation1 cdtTrfTxInf = null;
    PaymentIdentification1 pmtId = null;
    AmountType2Choice amt = null;
    CurrencyAndAmount instdAmt = null;
    PartyIdentification8 cbtr = null;
    CashAccount7 cbtrAcct = null;
    BranchAndFinancialInstitutionIdentification3 cbtrAgt = null;
    RemittanceInformation1 rmtInf = null;
    for (BankOrderLine bankOrderLine : bankOrderLineList) {
        BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
        // Reference
        pmtId = factory.createPaymentIdentification1();
        // pmtId.setInstrId(bankOrderLine.getSequence());
        pmtId.setEndToEndId(bankOrderLine.getSequence());
        // Amount
        instdAmt = factory.createCurrencyAndAmount();
        instdAmt.setCcy(bankOrderCurrency.getCode());
        instdAmt.setValue(bankOrderLine.getBankOrderAmount());
        amt = factory.createAmountType2Choice();
        amt.setInstdAmt(instdAmt);
        // Receiver
        cbtr = factory.createPartyIdentification8();
        cbtr.setNm(receiverBankDetails.getOwnerName());
        // IBAN
        iban = factory.createAccountIdentification3Choice();
        iban.setIBAN(receiverBankDetails.getIban());
        cbtrAcct = factory.createCashAccount7();
        cbtrAcct.setId(iban);
        // BIC
        finInstnId = factory.createFinancialInstitutionIdentification5Choice();
        fillBic(finInstnId, receiverBankDetails.getBank());
        cbtrAgt = factory.createBranchAndFinancialInstitutionIdentification3();
        cbtrAgt.setFinInstnId(finInstnId);
        rmtInf = factory.createRemittanceInformation1();
        String ustrd = "";
        if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverReference())) {
            ustrd += bankOrderLine.getReceiverReference();
        }
        if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverLabel())) {
            if (!Strings.isNullOrEmpty(ustrd)) {
                ustrd += " - ";
            }
            ustrd += bankOrderLine.getReceiverLabel();
        }
        if (!Strings.isNullOrEmpty(ustrd)) {
            rmtInf.getUstrd().add(ustrd);
        }
        // StructuredRemittanceInformation6 strd = factory.createStructuredRemittanceInformation6();
        // 
        // CreditorReferenceInformation1 cdtrRefInf = factory.createCreditorReferenceInformation1();
        // cdtrRefInf.setCdtrRef(bankOrderLine.getReceiverReference());
        // 
        // strd.setCdtrRefInf(cdtrRefInf);
        // 
        // rmtInf.getStrd().add(strd);
        // Transaction
        cdtTrfTxInf = factory.createCreditTransferTransactionInformation1();
        cdtTrfTxInf.setPmtId(pmtId);
        cdtTrfTxInf.setAmt(amt);
        cdtTrfTxInf.setCdtr(cbtr);
        cdtTrfTxInf.setCdtrAcct(cbtrAcct);
        cdtTrfTxInf.setCdtrAgt(cbtrAgt);
        cdtTrfTxInf.setRmtInf(rmtInf);
        pmtInf.getCdtTrfTxInf().add(cdtTrfTxInf);
    }
    // Header
    GroupHeader1 grpHdr = factory.createGroupHeader1();
    /**
     * Référence du message qui n'est pas utilisée comme référence fonctionnelle.
     */
    grpHdr.setMsgId(bankOrderSeq);
    /**
     * CreationDateTime Definition : Date and Time at which a (group of) payment instruction(s) was
     * created by the instructing party. XML Tag : <CreDtTm> Occurrences : [1..1] Format :
     * YYYY-MM-DDThh:mm:ss
     */
    grpHdr.setCreDtTm(datatypeFactory.newXMLGregorianCalendar(generationDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))));
    grpHdr.setNbOfTxs(Integer.toString(nbOfLines));
    grpHdr.setCtrlSum(arithmeticTotal);
    grpHdr.setGrpg(Grouping1Code.MIXD);
    grpHdr.setInitgPty(dbtr);
    // Parent
    Pain00100102 pain00100102 = factory.createPain00100102();
    pain00100102.setGrpHdr(grpHdr);
    pain00100102.getPmtInf().add(pmtInf);
    // Document
    Document xml = factory.createDocument();
    xml.setPain00100102(pain00100102);
    fileToCreate = factory.createDocument(xml);
    return super.generateFile();
}
Also used : CreditTransferTransactionInformation1(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.CreditTransferTransactionInformation1) BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) DatatypeFactory(javax.xml.datatype.DatatypeFactory) PartyIdentification8(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.PartyIdentification8) BranchAndFinancialInstitutionIdentification3(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.BranchAndFinancialInstitutionIdentification3) BankDetails(com.axelor.apps.base.db.BankDetails) AccountIdentification3Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.AccountIdentification3Choice) ServiceLevel2Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.ServiceLevel2Choice) CurrencyAndAmount(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.CurrencyAndAmount) PaymentTypeInformation1(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.PaymentTypeInformation1) AmountType2Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.AmountType2Choice) Document(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.Document) RemittanceInformation1(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.RemittanceInformation1) ObjectFactory(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.ObjectFactory) CashAccount7(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.CashAccount7) PaymentIdentification1(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.PaymentIdentification1) Pain00100102(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.Pain00100102) PaymentInstructionInformation1(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.PaymentInstructionInformation1) GroupHeader1(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.GroupHeader1) FinancialInstitutionIdentification5Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_02.FinancialInstitutionIdentification5Choice)

Example 44 with ObjectFactory

use of net.opengis.cat.csw._3.ObjectFactory in project axelor-open-suite by axelor.

the class BankOrderFile00100103Service method generateFile.

/**
 * Method to create an XML file for SEPA transfer pain.001.001.03
 *
 * @throws AxelorException
 * @throws DatatypeConfigurationException
 * @throws JAXBException
 * @throws IOException
 */
@Override
public File generateFile() throws JAXBException, IOException, AxelorException, DatatypeConfigurationException {
    DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
    ObjectFactory factory = new ObjectFactory();
    ServiceLevel8Choice svcLvl = factory.createServiceLevel8Choice();
    svcLvl.setCd("SEPA");
    PaymentTypeInformation19 pmtTpInf = factory.createPaymentTypeInformation19();
    pmtTpInf.setSvcLvl(svcLvl);
    // Payer
    PartyIdentification32 dbtr = factory.createPartyIdentification32();
    dbtr.setNm(senderBankDetails.getOwnerName());
    // IBAN
    AccountIdentification4Choice iban = factory.createAccountIdentification4Choice();
    iban.setIBAN(senderBankDetails.getIban());
    CashAccount16 dbtrAcct = factory.createCashAccount16();
    dbtrAcct.setId(iban);
    // BIC
    FinancialInstitutionIdentification7 finInstnId = factory.createFinancialInstitutionIdentification7();
    fillBic(finInstnId, senderBankDetails.getBank());
    BranchAndFinancialInstitutionIdentification4 dbtrAgt = factory.createBranchAndFinancialInstitutionIdentification4();
    dbtrAgt.setFinInstnId(finInstnId);
    PaymentInstructionInformation3 pmtInf = factory.createPaymentInstructionInformation3();
    pmtInf.setPmtInfId(bankOrderSeq);
    pmtInf.setPmtMtd(PaymentMethod3Code.TRF);
    pmtInf.setPmtTpInf(pmtTpInf);
    /**
     * RequestedExecutionDate Definition : Date at which the initiating party asks the Debtor's Bank
     * to process the payment. This is the date on which the debtor's account(s) is (are) to be
     * debited. XML Tag : <ReqdExctnDt> Occurrences : [1..1] Format : YYYY-MM-DD Rules : date is
     * limited to maximum one year in the future.
     */
    pmtInf.setReqdExctnDt(datatypeFactory.newXMLGregorianCalendar(bankOrderDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))));
    pmtInf.setDbtr(dbtr);
    pmtInf.setDbtrAcct(dbtrAcct);
    pmtInf.setDbtrAgt(dbtrAgt);
    CreditTransferTransactionInformation10 cdtTrfTxInf = null;
    PaymentIdentification1 pmtId = null;
    AmountType3Choice amt = null;
    ActiveOrHistoricCurrencyAndAmount instdAmt = null;
    PartyIdentification32 cbtr = null;
    CashAccount16 cbtrAcct = null;
    BranchAndFinancialInstitutionIdentification4 cbtrAgt = null;
    RemittanceInformation5 rmtInf = null;
    for (BankOrderLine bankOrderLine : bankOrderLineList) {
        BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
        // Reference
        pmtId = factory.createPaymentIdentification1();
        // pmtId.setInstrId(bankOrderLine.getSequence());
        pmtId.setEndToEndId(bankOrderLine.getSequence());
        // Amount
        instdAmt = factory.createActiveOrHistoricCurrencyAndAmount();
        instdAmt.setCcy(bankOrderCurrency.getCode());
        instdAmt.setValue(bankOrderLine.getBankOrderAmount());
        amt = factory.createAmountType3Choice();
        amt.setInstdAmt(instdAmt);
        // Receiver
        cbtr = factory.createPartyIdentification32();
        cbtr.setNm(receiverBankDetails.getOwnerName());
        // IBAN
        iban = factory.createAccountIdentification4Choice();
        iban.setIBAN(receiverBankDetails.getIban());
        cbtrAcct = factory.createCashAccount16();
        cbtrAcct.setId(iban);
        // BIC
        finInstnId = factory.createFinancialInstitutionIdentification7();
        fillBic(finInstnId, receiverBankDetails.getBank());
        cbtrAgt = factory.createBranchAndFinancialInstitutionIdentification4();
        cbtrAgt.setFinInstnId(finInstnId);
        rmtInf = factory.createRemittanceInformation5();
        String ustrd = "";
        if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverReference())) {
            ustrd += bankOrderLine.getReceiverReference();
        }
        if (!Strings.isNullOrEmpty(bankOrderLine.getReceiverLabel())) {
            if (!Strings.isNullOrEmpty(ustrd)) {
                ustrd += " - ";
            }
            ustrd += bankOrderLine.getReceiverLabel();
        }
        if (!Strings.isNullOrEmpty(ustrd)) {
            rmtInf.getUstrd().add(ustrd);
        }
        // StructuredRemittanceInformation7 strd = factory.createStructuredRemittanceInformation7();
        // 
        // CreditorReferenceInformation2 cdtrRefInf = factory.createCreditorReferenceInformation2();
        // cdtrRefInf.setRef(bankOrderLine.getReceiverReference());
        // 
        // strd.setCdtrRefInf(cdtrRefInf);
        // 
        // rmtInf.getStrd().add(strd);
        // Transaction
        cdtTrfTxInf = factory.createCreditTransferTransactionInformation10();
        cdtTrfTxInf.setPmtId(pmtId);
        cdtTrfTxInf.setAmt(amt);
        cdtTrfTxInf.setCdtr(cbtr);
        cdtTrfTxInf.setCdtrAcct(cbtrAcct);
        cdtTrfTxInf.setCdtrAgt(cbtrAgt);
        cdtTrfTxInf.setRmtInf(rmtInf);
        pmtInf.getCdtTrfTxInf().add(cdtTrfTxInf);
    }
    // Header
    GroupHeader32 grpHdr = factory.createGroupHeader32();
    /**
     * Référence du message qui n'est pas utilisée comme référence fonctionnelle.
     */
    grpHdr.setMsgId(bankOrderSeq);
    /**
     * CreationDateTime Definition : Date and Time at which a (group of) payment instruction(s) was
     * created by the instructing party. XML Tag : <CreDtTm> Occurrences : [1..1] Format :
     * YYYY-MM-DDThh:mm:ss
     */
    grpHdr.setCreDtTm(datatypeFactory.newXMLGregorianCalendar(generationDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss"))));
    grpHdr.setNbOfTxs(Integer.toString(nbOfLines));
    grpHdr.setCtrlSum(arithmeticTotal);
    grpHdr.setInitgPty(dbtr);
    // Parent
    CustomerCreditTransferInitiationV03 customerCreditTransferInitiationV03 = factory.createCustomerCreditTransferInitiationV03();
    customerCreditTransferInitiationV03.setGrpHdr(grpHdr);
    customerCreditTransferInitiationV03.getPmtInf().add(pmtInf);
    // Document
    Document xml = factory.createDocument();
    xml.setCstmrCdtTrfInitn(customerCreditTransferInitiationV03);
    fileToCreate = factory.createDocument(xml);
    return super.generateFile();
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) DatatypeFactory(javax.xml.datatype.DatatypeFactory) ActiveOrHistoricCurrencyAndAmount(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.ActiveOrHistoricCurrencyAndAmount) BranchAndFinancialInstitutionIdentification4(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.BranchAndFinancialInstitutionIdentification4) BankDetails(com.axelor.apps.base.db.BankDetails) CashAccount16(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.CashAccount16) Document(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.Document) PartyIdentification32(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.PartyIdentification32) AmountType3Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.AmountType3Choice) ObjectFactory(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.ObjectFactory) RemittanceInformation5(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.RemittanceInformation5) GroupHeader32(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.GroupHeader32) PaymentTypeInformation19(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.PaymentTypeInformation19) PaymentIdentification1(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.PaymentIdentification1) CreditTransferTransactionInformation10(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.CreditTransferTransactionInformation10) ServiceLevel8Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.ServiceLevel8Choice) FinancialInstitutionIdentification7(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.FinancialInstitutionIdentification7) PaymentInstructionInformation3(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.PaymentInstructionInformation3) CustomerCreditTransferInitiationV03(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.CustomerCreditTransferInitiationV03) AccountIdentification4Choice(com.axelor.apps.bankpayment.xsd.sepa.pain_001_001_03.AccountIdentification4Choice)

Example 45 with ObjectFactory

use of net.opengis.cat.csw._3.ObjectFactory in project RouteConverter by cpesch.

the class GpxPositionExtension method setHeading.

public void setHeading(Double heading) {
    if (wptType.getExtensions() == null)
        wptType.setExtensions(new ObjectFactory().createExtensionsType());
    List<Object> anys = wptType.getExtensions().getAny();
    boolean foundHeading = false;
    for (Object any : anys) {
        if (any instanceof JAXBElement) {
            Object anyValue = ((JAXBElement) any).getValue();
            if (anyValue instanceof slash.navigation.gpx.trackpoint2.TrackPointExtensionT) {
                slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPoint = (slash.navigation.gpx.trackpoint2.TrackPointExtensionT) anyValue;
                trackPoint.setCourse(formatHeading(heading));
                foundHeading = true;
            }
        } else if (any instanceof Element) {
            Element element = (Element) any;
            if ("course".equalsIgnoreCase(element.getLocalName())) {
                element.setTextContent(formatHeadingAsString(heading));
                foundHeading = true;
            }
        }
    }
    if (!foundHeading) {
        slash.navigation.gpx.trackpoint2.ObjectFactory trackpoint2Factory = new slash.navigation.gpx.trackpoint2.ObjectFactory();
        slash.navigation.gpx.trackpoint2.TrackPointExtensionT trackPointExtensionT = trackpoint2Factory.createTrackPointExtensionT();
        trackPointExtensionT.setCourse(formatHeading(heading));
        anys.add(trackpoint2Factory.createTrackPointExtension(trackPointExtensionT));
    }
}
Also used : JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) JAXBElement(javax.xml.bind.JAXBElement) ObjectFactory(slash.navigation.gpx.binding11.ObjectFactory)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)32 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)25 Marshaller (javax.xml.bind.Marshaller)22 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)20 StringWriter (java.io.StringWriter)18 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)18 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 ObjectFactory (no.seres.xsd.nav.inntektsmelding_m._20181211.ObjectFactory)16 JAXBContext (javax.xml.bind.JAXBContext)14 QName (javax.xml.namespace.QName)13 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)13 XStream (com.thoughtworks.xstream.XStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)12 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)12 ObjectFactory (slash.navigation.kml.binding22.ObjectFactory)12 ObjectFactory (com.opensymphony.xwork2.ObjectFactory)11 BigInteger (java.math.BigInteger)11 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)11