use of net.opengis.gml._3.ObjectFactory in project fix-orchestra by FIXTradingCommunity.
the class RepositoryCompressor method compress.
private boolean compress(InputStream is, OutputStream os, Predicate<? super MessageType> messagePredicate) {
try {
final Repository inRepository = unmarshal(is);
final Categories categories = inRepository.getCategories();
isCategoryInSection.setCategories(categories.getCategory());
final Repository outRepository = new Repository();
inRepository.copyTo(null, outRepository, AttributeCopyStrategy.INSTANCE);
final ElementOrRefinementContainer metadata = (ElementOrRefinementContainer) inRepository.getMetadata().clone();
final List<JAXBElement<SimpleLiteral>> literals = metadata.getAny();
final ObjectFactory objectFactory = new ObjectFactory();
final SimpleLiteral contributor = new SimpleLiteral();
contributor.getContent().add("RepositoryCompressor");
literals.add(objectFactory.createContributor(contributor));
outRepository.setMetadata(metadata);
if (categories != null) {
outRepository.setCategories((Categories) categories.clone());
}
final Sections sections = inRepository.getSections();
if (sections != null) {
outRepository.setSections((Sections) sections.clone());
}
final Datatypes datatypes = inRepository.getDatatypes();
if (datatypes != null) {
outRepository.setDatatypes((Datatypes) datatypes.clone());
}
final Actors actors = inRepository.getActors();
if (actors != null) {
outRepository.setActors((Actors) actors.clone());
}
final Components components = inRepository.getComponents();
if (components != null) {
final Components inComponents = (Components) components.clone();
componentList = inComponents.getComponent();
}
final Groups groups = inRepository.getGroups();
if (groups != null) {
final Groups inGroups = (Groups) groups.clone();
groupList = inGroups.getGroup();
}
final Messages messages = inRepository.getMessages();
final List<MessageType> messageList;
if (messages != null) {
final Messages inMessages = (Messages) messages.clone();
messageList = inMessages.getMessage();
} else {
messageList = Collections.emptyList();
}
final List<MessageType> filteredMessages = messageList.stream().filter(messagePredicate).collect(Collectors.toList());
filteredMessages.forEach(m -> walk(m.getStructure().getComponentRefOrGroupRefOrFieldRef()));
final List<BigInteger> distinctFieldIds = fieldIdList.stream().distinct().collect(Collectors.toList());
final Fields inFields = (Fields) inRepository.getFields().clone();
final List<FieldType> fieldsWithFlow = inFields.getField().stream().filter(f -> distinctFieldIds.contains(f.getId())).collect(Collectors.toList());
final Fields outFields = new Fields();
outFields.getField().addAll(fieldsWithFlow);
outRepository.setFields(outFields);
final List<String> typeList = fieldsWithFlow.stream().map(FieldType::getType).distinct().collect(Collectors.toList());
final CodeSets inCodeSets = (CodeSets) inRepository.getCodeSets().clone();
final List<CodeSetType> codeSetsWithFlow = inCodeSets.getCodeSet().stream().filter(cs -> typeList.contains(cs.getName())).collect(Collectors.toList());
final CodeSets outCodeSets = new CodeSets();
outCodeSets.getCodeSet().addAll(codeSetsWithFlow);
outRepository.setCodeSets(outCodeSets);
final List<BigInteger> distinctComponentsIds = componentIdList.stream().distinct().collect(Collectors.toList());
final List<ComponentType> componentsWithFlow = componentList.stream().filter(c -> distinctComponentsIds.contains(c.getId())).collect(Collectors.toList());
final Components outComponents = new Components();
outComponents.getComponent().addAll(componentsWithFlow);
outRepository.setComponents(outComponents);
final List<BigInteger> distinctGroupIds = groupIdList.stream().distinct().collect(Collectors.toList());
final List<GroupType> groupWithFlow = groupList.stream().filter(c -> distinctGroupIds.contains(c.getId())).collect(Collectors.toList());
final Groups outGroups = new Groups();
outGroups.getGroup().addAll(groupWithFlow);
outRepository.setGroups(outGroups);
final Messages outMessages = new Messages();
outMessages.getMessage().addAll(filteredMessages);
outRepository.setMessages(outMessages);
marshal(outRepository, os);
return true;
} catch (JAXBException e) {
logger.fatal("RepositoryCompressor failed", e);
return false;
}
}
use of net.opengis.gml._3.ObjectFactory in project phoss-smp by phax.
the class MainCreate1MillionEndpoints method main.
public static void main(final String[] args) throws Throwable {
final SMPServerRESTTestRule aRule = new SMPServerRESTTestRule(ClassPathResource.getAsFile("test-smp-server-mongodb.properties").getAbsolutePath());
aRule.before();
try {
// Set the special PhotonSecurityManager factory
PhotonSecurityManager.setFactory(new PhotonSecurityManagerFactoryMongoDB());
final ObjectFactory aObjFactory = new ObjectFactory();
final PeppolDocumentTypeIdentifier aDT = EPredefinedDocumentTypeIdentifier.INVOICE_EN16931_PEPPOL_V30.getAsDocumentTypeIdentifier();
final String sDT = aDT.getURIEncoded();
final PeppolProcessIdentifier aProcID = EPredefinedProcessIdentifier.BIS3_BILLING.getAsProcessIdentifier();
final StopWatch aSWOverall = StopWatch.createdStarted();
for (int i = 639276; i < 1_000_000; ++i) {
final StopWatch aSW = StopWatch.createdStarted();
final PeppolParticipantIdentifier aPI = PeppolIdentifierFactory.INSTANCE.createParticipantIdentifierWithDefaultScheme("9999:test-philip-" + StringHelper.getLeadingZero(i, 7));
final String sPI = aPI.getURIEncoded();
final ServiceMetadataType aSM = new ServiceMetadataType();
final ServiceInformationType aSI = new ServiceInformationType();
aSI.setParticipantIdentifier(new SimpleParticipantIdentifier(aPI));
aSI.setDocumentIdentifier(aDT);
{
final ProcessListType aPL = new ProcessListType();
final ProcessType aProcess = new ProcessType();
aProcess.setProcessIdentifier(aProcID);
final ServiceEndpointList aSEL = new ServiceEndpointList();
final EndpointType aEndpoint = new EndpointType();
aEndpoint.setEndpointReference(W3CEndpointReferenceHelper.createEndpointReference("http://test.smpserver/as2"));
aEndpoint.setRequireBusinessLevelSignature(false);
aEndpoint.setCertificate("blacert");
aEndpoint.setServiceDescription("Unit test service");
aEndpoint.setTechnicalContactUrl("https://github.com/phax/phoss-smp");
aEndpoint.setTransportProfile(ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID());
aSEL.addEndpoint(aEndpoint);
aProcess.setServiceEndpointList(aSEL);
aPL.addProcess(aProcess);
aSI.setProcessList(aPL);
}
aSM.setServiceInformation(aSI);
try (final WebScoped aWS = new WebScoped(new MockHttpServletRequest())) {
// Delete old - don't care about the result
if (false)
ClientBuilder.newClient().target(aRule.getFullURL()).path(sPI).path("services").path(sDT).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).delete();
// Create a new
final Response aResponseMsg = ClientBuilder.newClient().target(aRule.getFullURL()).path(sPI).path("services").path(sDT).request().header(CHttpHeader.AUTHORIZATION, CREDENTIALS.getRequestValue()).put(Entity.xml(aObjFactory.createServiceMetadata(aSM)));
_testResponseJerseyClient(aResponseMsg, 200);
}
aSW.stop();
LOGGER.info(sPI + " took " + aSW.getMillis() + " ms");
}
aSWOverall.stop();
LOGGER.info("Overall process took " + aSWOverall.getMillis() + " ms or " + aSWOverall.getDuration());
} finally {
aRule.after();
}
}
use of net.opengis.gml._3.ObjectFactory in project testnorge by navikt.
the class ArbeidsforholdDTO method toXmlElement.
@Override
public XMLArbeidsforhold toXmlElement() {
ObjectFactory factory = new ObjectFactory();
XMLArbeidsforhold xmlArbeidsforhold = factory.createXMLArbeidsforhold();
if (utsettelseAvForeldrepengerListe != null) {
XMLUtsettelseAvForeldrepengerListe xmlUtsettelseAvForeldrepengerListe = factory.createXMLUtsettelseAvForeldrepengerListe();
xmlUtsettelseAvForeldrepengerListe.withUtsettelseAvForeldrepenger(UtsettelseAvForeldrepengerDTO.convert(utsettelseAvForeldrepengerListe));
xmlArbeidsforhold.setUtsettelseAvForeldrepengerListe(factory.createXMLArbeidsforholdUtsettelseAvForeldrepengerListe(xmlUtsettelseAvForeldrepengerListe));
}
if (graderingIForeldrepengerListe != null) {
XMLGraderingIForeldrepengerListe xmlGraderingIForeldrepengerListe = factory.createXMLGraderingIForeldrepengerListe();
xmlGraderingIForeldrepengerListe.withGraderingIForeldrepenger(GraderingIForeldrepengerDTO.convert(graderingIForeldrepengerListe));
xmlArbeidsforhold.setGraderingIForeldrepengerListe(factory.createXMLArbeidsforholdGraderingIForeldrepengerListe(xmlGraderingIForeldrepengerListe));
}
if (avtaltFerieListe != null) {
XMLAvtaltFerieListe xmlAvtaltFerieListe = factory.createXMLAvtaltFerieListe();
xmlAvtaltFerieListe.withAvtaltFerie(PeriodeDTO.convert(avtaltFerieListe));
xmlArbeidsforhold.setAvtaltFerieListe(factory.createXMLArbeidsforholdAvtaltFerieListe(xmlAvtaltFerieListe));
}
if (beregnetInntekt != null) {
xmlArbeidsforhold.setBeregnetInntekt(factory.createXMLArbeidsforholdBeregnetInntekt(beregnetInntekt.toXmlElement()));
}
if (Strings.isNotBlank(arbeidsforholdId)) {
xmlArbeidsforhold.setArbeidsforholdId(factory.createXMLArbeidsforholdArbeidsforholdId(arbeidsforholdId));
}
xmlArbeidsforhold.setFoersteFravaersdag(factory.createXMLArbeidsforholdFoersteFravaersdag(foersteFravaersdag));
return xmlArbeidsforhold;
}
use of net.opengis.gml._3.ObjectFactory in project testnorge by navikt.
the class ArbeidsgiverDTO method toXmlElement.
@Override
public XMLArbeidsgiver toXmlElement() {
ObjectFactory factory = new ObjectFactory();
XMLArbeidsgiver xmlArbeidsgiver = factory.createXMLArbeidsgiver();
xmlArbeidsgiver.setVirksomhetsnummer(virksomhetsnummer);
if (kontaktinformasjon != null) {
xmlArbeidsgiver.setKontaktinformasjon(kontaktinformasjon.toXmlElement());
}
return xmlArbeidsgiver;
}
use of net.opengis.gml._3.ObjectFactory in project testnorge by navikt.
the class InntektDTO method toXmlElement.
@Override
public XMLInntekt toXmlElement() {
ObjectFactory factory = new ObjectFactory();
XMLInntekt xmlInntekt = factory.createXMLInntekt();
xmlInntekt.setAarsakVedEndring(factory.createXMLInntektAarsakVedEndring(aarsakVedEndring));
xmlInntekt.setBeloep(factory.createXMLInntektBeloep(beloep != null ? BigDecimal.valueOf(beloep) : null));
return xmlInntekt;
}
Aggregations