Reformat rest of the design patterns - Issue #224

This commit is contained in:
Ankur Kaushal
2015-11-01 21:29:13 -05:00
parent 449340bd2b
commit 306b1f3d31
337 changed files with 6744 additions and 6851 deletions

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.dom.app.homepage;
@ -25,27 +21,25 @@ import org.apache.isis.applib.annotation.HomePage;
import org.apache.isis.applib.annotation.NatureOfService;
import org.apache.isis.applib.annotation.SemanticsOf;
@DomainService(
nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY // trick to suppress the actions from the top-level menu
@DomainService(nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY // trick to suppress the actions
// from the top-level menu
)
public class HomePageService {
//region > homePage (action)
// region > homePage (action)
@Action(
semantics = SemanticsOf.SAFE
)
@HomePage
public HomePageViewModel homePage() {
return container.injectServicesInto(new HomePageViewModel());
}
@Action(semantics = SemanticsOf.SAFE)
@HomePage
public HomePageViewModel homePage() {
return container.injectServicesInto(new HomePageViewModel());
}
//endregion
// endregion
//region > injected services
// region > injected services
@javax.inject.Inject
DomainObjectContainer container;
@javax.inject.Inject
DomainObjectContainer container;
//endregion
// endregion
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.dom.app.homepage;
@ -28,23 +24,25 @@ import domainapp.dom.modules.simple.SimpleObjects;
@ViewModel
public class HomePageViewModel {
//region > title
public String title() {
return getObjects().size() + " objects";
}
//endregion
// region > title
public String title() {
return getObjects().size() + " objects";
}
//region > object (collection)
@org.apache.isis.applib.annotation.HomePage
public List<SimpleObject> getObjects() {
return simpleObjects.listAll();
}
//endregion
// endregion
//region > injected services
// region > object (collection)
@org.apache.isis.applib.annotation.HomePage
public List<SimpleObject> getObjects() {
return simpleObjects.listAll();
}
@javax.inject.Inject
SimpleObjects simpleObjects;
// endregion
//endregion
// region > injected services
@javax.inject.Inject
SimpleObjects simpleObjects;
// endregion
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.dom.modules.simple;
@ -37,113 +33,95 @@ import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
import org.apache.isis.applib.services.i18n.TranslatableString;
import org.apache.isis.applib.util.ObjectContracts;
@javax.jdo.annotations.PersistenceCapable(
identityType=IdentityType.DATASTORE,
schema = "simple",
table = "SimpleObject"
)
@javax.jdo.annotations.PersistenceCapable(identityType = IdentityType.DATASTORE, schema = "simple",
table = "SimpleObject")
@javax.jdo.annotations.DatastoreIdentity(
strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
column="id")
@javax.jdo.annotations.Version(
strategy=VersionStrategy.VERSION_NUMBER,
column="version")
strategy = javax.jdo.annotations.IdGeneratorStrategy.IDENTITY, column = "id")
@javax.jdo.annotations.Version(strategy = VersionStrategy.VERSION_NUMBER, column = "version")
@javax.jdo.annotations.Queries({
@javax.jdo.annotations.Query(
name = "find", language = "JDOQL",
value = "SELECT "
+ "FROM domainapp.dom.modules.simple.SimpleObject "),
@javax.jdo.annotations.Query(
name = "findByName", language = "JDOQL",
value = "SELECT "
+ "FROM domainapp.dom.modules.simple.SimpleObject "
+ "WHERE name.indexOf(:name) >= 0 ")
})
@javax.jdo.annotations.Unique(name="SimpleObject_name_UNQ", members = {"name"})
@javax.jdo.annotations.Query(name = "find", language = "JDOQL", value = "SELECT "
+ "FROM domainapp.dom.modules.simple.SimpleObject "),
@javax.jdo.annotations.Query(name = "findByName", language = "JDOQL", value = "SELECT "
+ "FROM domainapp.dom.modules.simple.SimpleObject " + "WHERE name.indexOf(:name) >= 0 ")})
@javax.jdo.annotations.Unique(name = "SimpleObject_name_UNQ", members = {"name"})
@DomainObject
@DomainObjectLayout(
bookmarking = BookmarkPolicy.AS_ROOT,
cssClassFa = "fa-flag"
)
@DomainObjectLayout(bookmarking = BookmarkPolicy.AS_ROOT, cssClassFa = "fa-flag")
public class SimpleObject implements Comparable<SimpleObject> {
//region > identificatiom
public TranslatableString title() {
return TranslatableString.tr("Object: {name}", "name", getName());
// region > identificatiom
public TranslatableString title() {
return TranslatableString.tr("Object: {name}", "name", getName());
}
// endregion
// region > name (property)
private String name;
@javax.jdo.annotations.Column(allowsNull = "false", length = 40)
@Title(sequence = "1")
@Property(editing = Editing.DISABLED)
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
// endregion
// region > updateName (action)
public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> {
public UpdateNameDomainEvent(final SimpleObject source, final Identifier identifier,
final Object... arguments) {
super(source, identifier, arguments);
}
//endregion
}
//region > name (property)
@Action(domainEvent = UpdateNameDomainEvent.class)
public SimpleObject updateName(
@Parameter(maxLength = 40) @ParameterLayout(named = "New name") final String name) {
setName(name);
return this;
}
private String name;
public String default0UpdateName() {
return getName();
}
@javax.jdo.annotations.Column(allowsNull="false", length = 40)
@Title(sequence="1")
@Property(
editing = Editing.DISABLED
)
public String getName() {
return name;
}
public TranslatableString validateUpdateName(final String name) {
return name.contains("!") ? TranslatableString.tr("Exclamation mark is not allowed") : null;
}
public void setName(final String name) {
this.name = name;
}
// endregion
// endregion
// region > version (derived property)
public Long getVersionSequence() {
return (Long) JDOHelper.getVersion(this);
}
//region > updateName (action)
// endregion
public static class UpdateNameDomainEvent extends ActionDomainEvent<SimpleObject> {
public UpdateNameDomainEvent(final SimpleObject source, final Identifier identifier, final Object... arguments) {
super(source, identifier, arguments);
}
}
// region > compareTo
@Action(
domainEvent = UpdateNameDomainEvent.class
)
public SimpleObject updateName(
@Parameter(maxLength = 40)
@ParameterLayout(named = "New name")
final String name) {
setName(name);
return this;
}
@Override
public int compareTo(final SimpleObject other) {
return ObjectContracts.compare(this, other, "name");
}
public String default0UpdateName() {
return getName();
}
// endregion
public TranslatableString validateUpdateName(final String name) {
return name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
}
// region > injected services
//endregion
@javax.inject.Inject
@SuppressWarnings("unused")
private DomainObjectContainer container;
//region > version (derived property)
public Long getVersionSequence() {
return (Long) JDOHelper.getVersion(this);
}
//endregion
//region > compareTo
@Override
public int compareTo(final SimpleObject other) {
return ObjectContracts.compare(this, other, "name");
}
//endregion
//region > injected services
@javax.inject.Inject
@SuppressWarnings("unused")
private DomainObjectContainer container;
//endregion
// endregion
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.dom.modules.simple;
@ -38,70 +34,56 @@ import org.apache.isis.applib.services.i18n.TranslatableString;
@DomainServiceLayout(menuOrder = "10")
public class SimpleObjects {
//region > title
public TranslatableString title() {
return TranslatableString.tr("Simple Objects");
// region > title
public TranslatableString title() {
return TranslatableString.tr("Simple Objects");
}
// endregion
// region > listAll (action)
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "1")
public List<SimpleObject> listAll() {
return container.allInstances(SimpleObject.class);
}
// endregion
// region > findByName (action)
@Action(semantics = SemanticsOf.SAFE)
@ActionLayout(bookmarking = BookmarkPolicy.AS_ROOT)
@MemberOrder(sequence = "2")
public List<SimpleObject> findByName(@ParameterLayout(named = "Name") final String name) {
return container.allMatches(new QueryDefault<>(SimpleObject.class, "findByName", "name", name));
}
// endregion
// region > create (action)
public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> {
public CreateDomainEvent(final SimpleObjects source, final Identifier identifier,
final Object... arguments) {
super(source, identifier, arguments);
}
//endregion
}
//region > listAll (action)
@Action(
semantics = SemanticsOf.SAFE
)
@ActionLayout(
bookmarking = BookmarkPolicy.AS_ROOT
)
@MemberOrder(sequence = "1")
public List<SimpleObject> listAll() {
return container.allInstances(SimpleObject.class);
}
//endregion
@Action(domainEvent = CreateDomainEvent.class)
@MemberOrder(sequence = "3")
public SimpleObject create(final @ParameterLayout(named = "Name") String name) {
final SimpleObject obj = container.newTransientInstance(SimpleObject.class);
obj.setName(name);
container.persistIfNotAlready(obj);
return obj;
}
//region > findByName (action)
@Action(
semantics = SemanticsOf.SAFE
)
@ActionLayout(
bookmarking = BookmarkPolicy.AS_ROOT
)
@MemberOrder(sequence = "2")
public List<SimpleObject> findByName(
@ParameterLayout(named="Name")
final String name
) {
return container.allMatches(
new QueryDefault<>(
SimpleObject.class,
"findByName",
"name", name));
}
//endregion
// endregion
//region > create (action)
public static class CreateDomainEvent extends ActionDomainEvent<SimpleObjects> {
public CreateDomainEvent(final SimpleObjects source, final Identifier identifier, final Object... arguments) {
super(source, identifier, arguments);
}
}
// region > injected services
@Action(
domainEvent = CreateDomainEvent.class
)
@MemberOrder(sequence = "3")
public SimpleObject create(
final @ParameterLayout(named="Name") String name) {
final SimpleObject obj = container.newTransientInstance(SimpleObject.class);
obj.setName(name);
container.persistIfNotAlready(obj);
return obj;
}
@javax.inject.Inject
DomainObjectContainer container;
//endregion
//region > injected services
@javax.inject.Inject
DomainObjectContainer container;
//endregion
// endregion
}

View File

@ -1,18 +1,16 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.dom.modules.simple;
@ -23,27 +21,27 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SimpleObjectTest {
SimpleObject simpleObject;
SimpleObject simpleObject;
@Before
public void setUp() throws Exception {
simpleObject = new SimpleObject();
}
public static class Name extends SimpleObjectTest {
@Test
public void happyCase() throws Exception {
// given
String name = "Foobar";
assertThat(simpleObject.getName()).isNull();
// when
simpleObject.setName(name);
// then
assertThat(simpleObject.getName()).isEqualTo(name);
}
@Before
public void setUp() throws Exception {
simpleObject = new SimpleObject();
}
public static class Name extends SimpleObjectTest {
@Test
public void happyCase() throws Exception {
// given
String name = "Foobar";
assertThat(simpleObject.getName()).isNull();
// when
simpleObject.setName(name);
// then
assertThat(simpleObject.getName()).isEqualTo(name);
}
}
}

View File

@ -1,18 +1,16 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.dom.modules.simple;
@ -35,70 +33,70 @@ import static org.assertj.core.api.Assertions.assertThat;
public class SimpleObjectsTest {
@Rule
public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
@Rule
public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
@Mock
DomainObjectContainer mockContainer;
SimpleObjects simpleObjects;
@Mock
DomainObjectContainer mockContainer;
@Before
public void setUp() throws Exception {
simpleObjects = new SimpleObjects();
simpleObjects.container = mockContainer;
}
SimpleObjects simpleObjects;
public static class Create extends SimpleObjectsTest {
@Before
public void setUp() throws Exception {
simpleObjects = new SimpleObjects();
simpleObjects.container = mockContainer;
}
@Test
public void happyCase() throws Exception {
public static class Create extends SimpleObjectsTest {
// given
final SimpleObject simpleObject = new SimpleObject();
@Test
public void happyCase() throws Exception {
final Sequence seq = context.sequence("create");
context.checking(new Expectations() {
{
oneOf(mockContainer).newTransientInstance(SimpleObject.class);
inSequence(seq);
will(returnValue(simpleObject));
// given
final SimpleObject simpleObject = new SimpleObject();
oneOf(mockContainer).persistIfNotAlready(simpleObject);
inSequence(seq);
}
});
final Sequence seq = context.sequence("create");
context.checking(new Expectations() {
{
oneOf(mockContainer).newTransientInstance(SimpleObject.class);
inSequence(seq);
will(returnValue(simpleObject));
// when
final SimpleObject obj = simpleObjects.create("Foobar");
// then
assertThat(obj).isEqualTo(simpleObject);
assertThat(obj.getName()).isEqualTo("Foobar");
oneOf(mockContainer).persistIfNotAlready(simpleObject);
inSequence(seq);
}
});
// when
final SimpleObject obj = simpleObjects.create("Foobar");
// then
assertThat(obj).isEqualTo(simpleObject);
assertThat(obj.getName()).isEqualTo("Foobar");
}
public static class ListAll extends SimpleObjectsTest {
}
@Test
public void happyCase() throws Exception {
public static class ListAll extends SimpleObjectsTest {
// given
final List<SimpleObject> all = Lists.newArrayList();
@Test
public void happyCase() throws Exception {
context.checking(new Expectations() {
{
oneOf(mockContainer).allInstances(SimpleObject.class);
will(returnValue(all));
}
});
// given
final List<SimpleObject> all = Lists.newArrayList();
// when
final List<SimpleObject> list = simpleObjects.listAll();
// then
assertThat(list).isEqualTo(all);
context.checking(new Expectations() {
{
oneOf(mockContainer).allInstances(SimpleObject.class);
will(returnValue(all));
}
});
// when
final List<SimpleObject> list = simpleObjects.listAll();
// then
assertThat(list).isEqualTo(all);
}
}
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.fixture;
@ -31,14 +27,12 @@ import domainapp.fixture.scenarios.RecreateSimpleObjects;
*/
@DomainService(nature = NatureOfService.DOMAIN)
public class DomainAppFixturesProvider implements FixtureScriptsSpecificationProvider {
@Override
public FixtureScriptsSpecification getSpecification() {
return FixtureScriptsSpecification
.builder(DomainAppFixturesProvider.class)
.with(FixtureScripts.MultipleExecutionStrategy.EXECUTE)
.withRunScriptDefault(RecreateSimpleObjects.class)
.withRunScriptDropDown(FixtureScriptsSpecification.DropDownPolicy.CHOICES)
.withRecreate(RecreateSimpleObjects.class)
.build();
}
@Override
public FixtureScriptsSpecification getSpecification() {
return FixtureScriptsSpecification.builder(DomainAppFixturesProvider.class)
.with(FixtureScripts.MultipleExecutionStrategy.EXECUTE)
.withRunScriptDefault(RecreateSimpleObjects.class)
.withRunScriptDropDown(FixtureScriptsSpecification.DropDownPolicy.CHOICES)
.withRecreate(RecreateSimpleObjects.class).build();
}
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.fixture.modules.simple;
@ -26,46 +22,50 @@ import domainapp.dom.modules.simple.SimpleObjects;
public class SimpleObjectCreate extends FixtureScript {
//region > name (input)
private String name;
/**
* Name of the object (required)
*/
public String getName() {
return name;
}
// region > name (input)
private String name;
public SimpleObjectCreate setName(final String name) {
this.name = name;
return this;
}
//endregion
/**
* Name of the object (required)
*/
public String getName() {
return name;
}
public SimpleObjectCreate setName(final String name) {
this.name = name;
return this;
}
// endregion
//region > simpleObject (output)
private SimpleObject simpleObject;
// region > simpleObject (output)
private SimpleObject simpleObject;
/**
* The created simple object (output).
* @return
*/
public SimpleObject getSimpleObject() {
return simpleObject;
}
//endregion
/**
* The created simple object (output).
*
* @return
*/
public SimpleObject getSimpleObject() {
return simpleObject;
}
@Override
protected void execute(final ExecutionContext ec) {
// endregion
String name = checkParam("name", ec, String.class);
@Override
protected void execute(final ExecutionContext ec) {
this.simpleObject = wrap(simpleObjects).create(name);
String name = checkParam("name", ec, String.class);
// also make available to UI
ec.addResult(this, simpleObject);
}
this.simpleObject = wrap(simpleObjects).create(name);
@javax.inject.Inject
private SimpleObjects simpleObjects;
// also make available to UI
ec.addResult(this, simpleObject);
}
@javax.inject.Inject
private SimpleObjects simpleObjects;
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.fixture.modules.simple;
@ -24,13 +20,13 @@ import org.apache.isis.applib.services.jdosupport.IsisJdoSupport;
public class SimpleObjectsTearDown extends FixtureScript {
@Override
protected void execute(ExecutionContext executionContext) {
isisJdoSupport.executeUpdate("delete from \"simple\".\"SimpleObject\"");
}
@Override
protected void execute(ExecutionContext executionContext) {
isisJdoSupport.executeUpdate("delete from \"simple\".\"SimpleObject\"");
}
@javax.inject.Inject
private IsisJdoSupport isisJdoSupport;
@javax.inject.Inject
private IsisJdoSupport isisJdoSupport;
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.fixture.scenarios;
@ -33,60 +29,63 @@ import domainapp.fixture.modules.simple.SimpleObjectsTearDown;
public class RecreateSimpleObjects extends FixtureScript {
public final List<String> NAMES = Collections.unmodifiableList(Arrays.asList(
"Foo", "Bar", "Baz", "Frodo", "Froyo", "Fizz", "Bip", "Bop", "Bang", "Boo"));
public final List<String> NAMES = Collections.unmodifiableList(Arrays.asList("Foo", "Bar", "Baz",
"Frodo", "Froyo", "Fizz", "Bip", "Bop", "Bang", "Boo"));
public RecreateSimpleObjects() {
withDiscoverability(Discoverability.DISCOVERABLE);
public RecreateSimpleObjects() {
withDiscoverability(Discoverability.DISCOVERABLE);
}
// region > number (optional input)
private Integer number;
/**
* The number of objects to create, up to 10; optional, defaults to 3.
*/
public Integer getNumber() {
return number;
}
public RecreateSimpleObjects setNumber(final Integer number) {
this.number = number;
return this;
}
// endregion
// region > simpleObjects (output)
private final List<SimpleObject> simpleObjects = Lists.newArrayList();
/**
* The simpleobjects created by this fixture (output).
*/
public List<SimpleObject> getSimpleObjects() {
return simpleObjects;
}
// endregion
@Override
protected void execute(final ExecutionContext ec) {
// defaults
final int number = defaultParam("number", ec, 3);
// validate
if (number < 0 || number > NAMES.size()) {
throw new IllegalArgumentException(String.format("number must be in range [0,%d)",
NAMES.size()));
}
//region > number (optional input)
private Integer number;
//
// execute
//
ec.executeChild(this, new SimpleObjectsTearDown());
/**
* The number of objects to create, up to 10; optional, defaults to 3.
*/
public Integer getNumber() {
return number;
}
public RecreateSimpleObjects setNumber(final Integer number) {
this.number = number;
return this;
}
//endregion
//region > simpleObjects (output)
private final List<SimpleObject> simpleObjects = Lists.newArrayList();
/**
* The simpleobjects created by this fixture (output).
*/
public List<SimpleObject> getSimpleObjects() {
return simpleObjects;
}
//endregion
@Override
protected void execute(final ExecutionContext ec) {
// defaults
final int number = defaultParam("number", ec, 3);
// validate
if(number < 0 || number > NAMES.size()) {
throw new IllegalArgumentException(String.format("number must be in range [0,%d)", NAMES.size()));
}
//
// execute
//
ec.executeChild(this, new SimpleObjectsTearDown());
for (int i = 0; i < number; i++) {
final SimpleObjectCreate fs = new SimpleObjectCreate().setName(NAMES.get(i));
ec.executeChild(this, fs.getName(), fs);
simpleObjects.add(fs.getSimpleObject());
}
for (int i = 0; i < number; i++) {
final SimpleObjectCreate fs = new SimpleObjectCreate().setName(NAMES.get(i));
ec.executeChild(this, fs.getName(), fs);
simpleObjects.add(fs.getSimpleObject());
}
}
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.integtests.bootstrap;
@ -25,30 +21,31 @@ import org.apache.isis.objectstore.jdo.datanucleus.IsisConfigurationForJdoIntegT
public class SimpleAppSystemInitializer {
public static void initIsft() {
IsisSystemForTest isft = IsisSystemForTest.getElseNull();
if(isft == null) {
isft = new SimpleAppSystemBuilder().build().setUpSystem();
IsisSystemForTest.set(isft);
}
public static void initIsft() {
IsisSystemForTest isft = IsisSystemForTest.getElseNull();
if (isft == null) {
isft = new SimpleAppSystemBuilder().build().setUpSystem();
IsisSystemForTest.set(isft);
}
}
private static class SimpleAppSystemBuilder extends IsisSystemForTest.Builder {
public SimpleAppSystemBuilder() {
withLoggingAt(org.apache.log4j.Level.INFO);
with(testConfiguration());
with(new DataNucleusPersistenceMechanismInstaller());
// services annotated with @DomainService
withServicesIn("domainapp");
}
private static class SimpleAppSystemBuilder extends IsisSystemForTest.Builder {
private static IsisConfiguration testConfiguration() {
final IsisConfigurationForJdoIntegTests testConfiguration =
new IsisConfigurationForJdoIntegTests();
public SimpleAppSystemBuilder() {
withLoggingAt(org.apache.log4j.Level.INFO);
with(testConfiguration());
with(new DataNucleusPersistenceMechanismInstaller());
// services annotated with @DomainService
withServicesIn( "domainapp" );
}
private static IsisConfiguration testConfiguration() {
final IsisConfigurationForJdoIntegTests testConfiguration = new IsisConfigurationForJdoIntegTests();
testConfiguration.addRegisterEntitiesPackagePrefix("domainapp.dom.modules");
return testConfiguration;
}
testConfiguration.addRegisterEntitiesPackagePrefix("domainapp.dom.modules");
return testConfiguration;
}
}
}

View File

@ -1,18 +1,16 @@
/**
O * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* O * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.integtests.specglue;
@ -25,17 +23,17 @@ import domainapp.integtests.bootstrap.SimpleAppSystemInitializer;
public class BootstrappingGlue extends CukeGlueAbstract {
@Before(value={"@integration"}, order=100)
public void beforeScenarioIntegrationScope() {
org.apache.log4j.PropertyConfigurator.configure("logging.properties");
SimpleAppSystemInitializer.initIsft();
before(ScenarioExecutionScope.INTEGRATION);
}
@Before(value = {"@integration"}, order = 100)
public void beforeScenarioIntegrationScope() {
org.apache.log4j.PropertyConfigurator.configure("logging.properties");
SimpleAppSystemInitializer.initIsft();
@After
public void afterScenario(cucumber.api.Scenario sc) {
assertMocksSatisfied();
after(sc);
}
before(ScenarioExecutionScope.INTEGRATION);
}
@After
public void afterScenario(cucumber.api.Scenario sc) {
assertMocksSatisfied();
after(sc);
}
}

View File

@ -1,18 +1,16 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.integtests.specglue;
@ -23,9 +21,8 @@ import domainapp.fixture.scenarios.RecreateSimpleObjects;
public class CatalogOfFixturesGlue extends CukeGlueAbstract {
@Before(value={"@integration", "@SimpleObjectsFixture"}, order=20000)
public void integrationFixtures() throws Throwable {
scenarioExecution().install(new RecreateSimpleObjects());
}
@Before(value = {"@integration", "@SimpleObjectsFixture"}, order = 20000)
public void integrationFixtures() throws Throwable {
scenarioExecution().install(new RecreateSimpleObjects());
}
}

View File

@ -1,18 +1,16 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.integtests.specglue.modules.simple;
@ -30,21 +28,21 @@ import static org.junit.Assert.assertThat;
public class SimpleObjectGlue extends CukeGlueAbstract {
@Given("^there are.* (\\d+) simple objects$")
public void there_are_N_simple_objects(int n) throws Throwable {
try {
final List<SimpleObject> findAll = service(SimpleObjects.class).listAll();
assertThat(findAll.size(), is(n));
putVar("list", "all", findAll);
} finally {
assertMocksSatisfied();
}
@Given("^there are.* (\\d+) simple objects$")
public void there_are_N_simple_objects(int n) throws Throwable {
try {
final List<SimpleObject> findAll = service(SimpleObjects.class).listAll();
assertThat(findAll.size(), is(n));
putVar("list", "all", findAll);
} finally {
assertMocksSatisfied();
}
@When("^I create a new simple object$")
public void I_create_a_new_simple_object() throws Throwable {
service(SimpleObjects.class).create(UUID.randomUUID().toString());
}
}
@When("^I create a new simple object$")
public void I_create_a_new_simple_object() throws Throwable {
service(SimpleObjects.class).create(UUID.randomUUID().toString());
}
}

View File

@ -1,18 +1,16 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.integtests.specs;
@ -23,17 +21,12 @@ import cucumber.api.junit.Cucumber;
/**
* Runs scenarios in all <tt>.feature</tt> files (this package and any subpackages).
* Runs scenarios in all <tt>.feature</tt> files (this package and any subpackages).
*/
@RunWith(Cucumber.class)
@CucumberOptions(
format = {
"html:target/cucumber-html-report"
,"json:target/cucumber.json"
},
glue={"classpath:domainapp.integtests.specglue"},
strict = true,
tags = { "~@backlog", "~@ignore" })
@CucumberOptions(format = {"html:target/cucumber-html-report", "json:target/cucumber.json"},
glue = {"classpath:domainapp.integtests.specglue"}, strict = true, tags = {"~@backlog",
"~@ignore"})
public class RunSpecs {
// intentionally empty
// intentionally empty
}

View File

@ -1,20 +1,16 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
* agreements. See the NOTICE file distributed with this work for additional information regarding
* copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License. You may obtain a
* copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package domainapp.webapp;
@ -53,6 +49,7 @@ import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvid
*
* <p>
* See:
*
* <pre>
* &lt;filter>
* &lt;filter-name>wicket&lt;/filter-name>
@ -67,87 +64,96 @@ import de.agilecoders.wicket.themes.markup.html.bootswatch.BootswatchThemeProvid
*/
public class SimpleApplication extends IsisWicketApplication {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* uncomment for a (slightly hacky) way of allowing logins using query args, eg:
*
* <tt>?user=sven&pass=pass</tt>
*
* <p>
* for demos only, obvious.
*/
private final static boolean DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS = false;
/**
* uncomment for a (slightly hacky) way of allowing logins using query args, eg:
*
* <tt>?user=sven&pass=pass</tt>
*
* <p>
* for demos only, obvious.
*/
private final static boolean DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS = false;
@Override
protected void init() {
super.init();
@Override
protected void init() {
super.init();
IBootstrapSettings settings = Bootstrap.getSettings();
settings.setThemeProvider(new BootswatchThemeProvider(BootswatchTheme.Flatly));
IBootstrapSettings settings = Bootstrap.getSettings();
settings.setThemeProvider(new BootswatchThemeProvider(BootswatchTheme.Flatly));
}
@Override
public Session newSession(final Request request, final Response response) {
if (!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
return super.newSession(request, response);
}
@Override
public Session newSession(final Request request, final Response response) {
if(!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
return super.newSession(request, response);
}
// else demo mode
final AuthenticatedWebSessionForIsis s = (AuthenticatedWebSessionForIsis) super.newSession(request, response);
IRequestParameters requestParameters = request.getRequestParameters();
final org.apache.wicket.util.string.StringValue user = requestParameters.getParameterValue("user");
final org.apache.wicket.util.string.StringValue password = requestParameters.getParameterValue("pass");
s.signIn(user.toString(), password.toString());
return s;
// else demo mode
final AuthenticatedWebSessionForIsis s =
(AuthenticatedWebSessionForIsis) super.newSession(request, response);
IRequestParameters requestParameters = request.getRequestParameters();
final org.apache.wicket.util.string.StringValue user =
requestParameters.getParameterValue("user");
final org.apache.wicket.util.string.StringValue password =
requestParameters.getParameterValue("pass");
s.signIn(user.toString(), password.toString());
return s;
}
@Override
public WebRequest newWebRequest(HttpServletRequest servletRequest, String filterPath) {
if (!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
return super.newWebRequest(servletRequest, filterPath);
}
@Override
public WebRequest newWebRequest(HttpServletRequest servletRequest, String filterPath) {
if(!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
return super.newWebRequest(servletRequest, filterPath);
}
// else demo mode
try {
String uname = servletRequest.getParameter("user");
if (uname != null) {
servletRequest.getSession().invalidate();
}
} catch (Exception e) {
}
WebRequest request = super.newWebRequest(servletRequest, filterPath);
return request;
// else demo mode
try {
String uname = servletRequest.getParameter("user");
if (uname != null) {
servletRequest.getSession().invalidate();
}
} catch (Exception e) {
}
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Simple App");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance("css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance("scripts/application.js");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Simple App");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
};
WebRequest request = super.newWebRequest(servletRequest, filterPath);
return request;
}
return Modules.override(isisDefaults).with(overrides);
}
@Override
protected Module newIsisWicketModule() {
final Module isisDefaults = super.newIsisWicketModule();
private static String readLines(final Class<?> contextClass, final String resourceName) {
try {
List<String> readLines = Resources.readLines(Resources.getResource(contextClass, resourceName), Charset.defaultCharset());
final String aboutText = Joiner.on("\n").join(readLines);
return aboutText;
} catch (IOException e) {
return "This is a simple app";
}
final Module overrides = new AbstractModule() {
@Override
protected void configure() {
bind(String.class).annotatedWith(Names.named("applicationName")).toInstance("Simple App");
bind(String.class).annotatedWith(Names.named("applicationCss")).toInstance(
"css/application.css");
bind(String.class).annotatedWith(Names.named("applicationJs")).toInstance(
"scripts/application.js");
bind(String.class).annotatedWith(Names.named("welcomeMessage")).toInstance(
readLines(getClass(), "welcome.html"));
bind(String.class).annotatedWith(Names.named("aboutMessage")).toInstance("Simple App");
bind(InputStream.class).annotatedWith(Names.named("metaInfManifest")).toProvider(
Providers.of(getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF")));
}
};
return Modules.override(isisDefaults).with(overrides);
}
private static String readLines(final Class<?> contextClass, final String resourceName) {
try {
List<String> readLines =
Resources.readLines(Resources.getResource(contextClass, resourceName),
Charset.defaultCharset());
final String aboutText = Joiner.on("\n").join(readLines);
return aboutText;
} catch (IOException e) {
return "This is a simple app";
}
}
}