Skip to content

Instantly share code, notes, and snippets.

View novoj's full-sized avatar
💻
Hacking on evitaDB

Jan Novotný novoj

💻
Hacking on evitaDB
View GitHub Profile
@novoj
novoj / gist:8744c54d116c437e8eef
Created August 8, 2014 12:53
Loooong lambda
SelectableItem matchingItem = getItems().stream()
.filter(selectableItem -> selectableItem.getTitle().equals(title))
.findFirst().orElseGet(() -> SelectableItem.EMPTY).getId();
/**
* Partial update allows AJAX partial update of the DOM structure by communicating with component background implemented
* in RamJet technology.
*
* Custom settings:
*
* alterHistory - boolean true - if browser history is ought to be altered,
* - boolean false - if browser history should remain untouched
* - (default) not set - only links/forms targeting the same page will alter the history
* historyScope - parameters - keeps only parameter values in history
package com.fg.doxx.gastro.web.user.validator;
import com.fg.doxx.gastro.business.GastroUserManager;
import com.fg.doxx.gastro.model.user.GastroUser;
import com.fg.form.core.context.RequestContext;
import com.fg.form.core.data.state.State;
import com.fg.form.core.lifecycle.validate.impl.AbstractSingleValueWidgetValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
@novoj
novoj / HackedDynamicMappingFilter.java
Last active December 23, 2015 06:29
Patch for Stripes framework on WebSphere 8.x
package net.sourceforge.stripes.controller;
import net.sourceforge.stripes.action.ActionBean;
import net.sourceforge.stripes.exception.StripesServletException;
import net.sourceforge.stripes.util.HttpUtil;
import net.sourceforge.stripes.util.Log;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
@novoj
novoj / bootstrapDictionary.xml
Created September 4, 2013 10:12
Bootstrap dictionary
<?xml version="1.0" encoding="utf-8"?>
<dictionary>
<widgets>
<rowFluid extends="widgetContainer" template="inherit">
<metadata>
<htmlClass>row-fluid</htmlClass>
</metadata>
</rowFluid>
<span1 extends="widgetContainer" template="inherit">
<metadata>
@novoj
novoj / ServletFreemarkerRenderer.java
Created August 28, 2013 12:13
ServletFreemarkerRenderer_part
public void render(RequestContext context, WidgetDefinition widgetDefinition, TemplateReference templateReference, ServletContext servletContext, HttpServletRequest request, HttpServletResponse response) throws TemplateNotFoundException, TemplateProcessingException {
try {
//we have to set encoding before writer is fetche
try {
response.setCharacterEncoding(configuration.getDefaultEncoding());
} catch (NoSuchMethodError e) {
// servlet spec 2.3
response.setContentType("text/html; encoding=" + configuration.getDefaultEncoding());
}
PageDefinition pageDefinition = (PageDefinition) context.getRequestable();
public class RunAsSupportTestExecutionListener extends AbstractTestExecutionListener {
private static final ThreadLocal<User> savedAuthentication = new ThreadLocal<User>();
@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
super.prepareTestInstance(testContext);
try {
testContext.getApplicationContext().getBean(CpsModuleSecuritySupport.class);
} catch (NoSuchBeanDefinitionException ignored) {
CpsModuleSupport moduleSupport = mock(CpsModuleSupport.class);
@novoj
novoj / RecipientListManagerTest.java
Created June 25, 2013 11:45
Recipient subscription from external application.
@Test
public void shouldSubscribeAlreadyConfirmedRecipientByExternalApplication() throws Exception {
Recipient rcp = recipientListManager.createNewRecipient();
rcp.setName("Uďo");
rcp.setAddress(new EmailAddress("novotnaci+udo@gmail.com"));
recipientListManager.subscribeConfirmedRecipient(rcp);
Recipient createdRcpt = recipientListManager.getRecipientByAddress("novotnaci+udo@gmail.com");
assertNotNull(createdRcpt);
assertEquals(RecipientState.Confirmed, createdRcpt.getState());
@novoj
novoj / EdeeUI
Last active December 18, 2015 12:29
V commandu:
@Autowired private EdeeUiAsyncConversationManager conversationMgr;
public Resolution perform(..) {
conversationMgr.addConversation(
new UiConversation() extends Conversation implements ApplicationListener {
public void onEvent(Application event) {
if (event instanceof BatchStoredEvent) {
@novoj
novoj / gui.xml
Created May 31, 2013 13:27
Mail module config
<?xml version="1.0" encoding="utf-8"?>
<gui>
<staticPage id="mail" storagePath="file:/www/p_java/cps/libs_java/prj_edeecms/prj_mail/lib_mail/src/main/resources/META-INF/lib_mail/templates/"> <!-- todo ${moduleName}, v MailModule uz je to pripravene -->
<dictionary>
<dataProviders>
<campaignRecordSource class="com.fg.mail.web.ramjet.campaign.datasource.CampaignRecordSource"/>
<campaignByTitleRecordSource class="com.fg.mail.web.ramjet.campaign.datasource.AggregatedCampaignRecordSource"/>
<recipientAutocompletionDataProvider class="com.fg.mail.web.ramjet.campaign.datasource.RecipientAutocompletionDataProvider"/>
<channelItemProvider class="com.fg.mail.web.ramjet.campaign.datasource.ChannelItemsProvider"/>