#91 Added skeleton for naked-objects example using Apache Isis SimpleApp archetype
This commit is contained in:
41
naked-objects/dom/log4j.properties
Normal file
41
naked-objects/dom/log4j.properties
Normal file
@ -0,0 +1,41 @@
|
||||
# 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.
|
||||
|
||||
# LOG4J Configuration
|
||||
# ===================
|
||||
|
||||
# Basic logging goes to "datanucleus.log"
|
||||
log4j.appender.A1=org.apache.log4j.FileAppender
|
||||
log4j.appender.A1.File=datanucleus.log
|
||||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.A1.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
|
||||
#log4j.appender.A1.Threshold=INFO
|
||||
|
||||
# Categories
|
||||
# Each category can be set to a "level", and to direct to an appender
|
||||
|
||||
# Default to DEBUG level for all DataNucleus categories
|
||||
log4j.logger.DataNucleus = DEBUG, A1
|
||||
|
||||
log4j.category.com.mchange.v2.c3p0=INFO, A1
|
||||
log4j.category.com.mchange.v2.resourcepool=INFO, A1
|
||||
log4j.category.org.logicalcobwebs.proxool=INFO,A1
|
||||
|
||||
|
||||
# Hbase libs logging
|
||||
log4j.category.org.apache.hadoop=INFO,A1
|
||||
log4j.category.org.apache.zookeeper=INFO,A1
|
194
naked-objects/dom/pom.xml
Normal file
194
naked-objects/dom/pom.xml
Normal file
@ -0,0 +1,194 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
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.
|
||||
--><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.iluwatar</groupId>
|
||||
<artifactId>naked-objects</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>naked-objects-dom</artifactId>
|
||||
<name>Simple App DOM</name>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.isis.core</groupId>
|
||||
<artifactId>isis-core-applib</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.isis.core</groupId>
|
||||
<artifactId>isis-core-unittestsupport</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Bytecode libraries (for mocking) -->
|
||||
<dependency>
|
||||
<groupId>org.objenesis</groupId>
|
||||
<artifactId>objenesis</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>enhance</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<datanucleus-maven-plugin.version>4.0.0-release</datanucleus-maven-plugin.version>
|
||||
</properties>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-maven-plugin</artifactId>
|
||||
<versionRange>[${datanucleus-maven-plugin.version},)</versionRange>
|
||||
<goals>
|
||||
<goal>enhance</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore></ignore>
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-maven-plugin</artifactId>
|
||||
<version>${datanucleus-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<fork>false</fork>
|
||||
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
|
||||
<verbose>true</verbose>
|
||||
<props>${basedir}/datanucleus.properties</props>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>enhance</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-jodatime</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.datanucleus</groupId>
|
||||
<artifactId>datanucleus-api-jdo</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>isis-validate</id>
|
||||
<activation>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.isis.tool</groupId>
|
||||
<artifactId>isis-maven-plugin</artifactId>
|
||||
<version>1.9.0-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<isisConfigDir>../webapp/src/main/webapp/WEB-INF</isisConfigDir>
|
||||
</configuration>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.isis.example.application</groupId>
|
||||
<artifactId>simpleapp-dom</artifactId>
|
||||
<version>1.9.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!--
|
||||
... workaround to avoid conflict with plexus-default
|
||||
(not sure why exclusions in the isis-maven-plugin aren't sufficient, though ...
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>16.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>validate</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</project>
|
26
naked-objects/dom/src/main/java/META-INF/persistence.xml
Normal file
26
naked-objects/dom/src/main/java/META-INF/persistence.xml
Normal file
@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
|
||||
|
||||
<persistence-unit name="simple">
|
||||
</persistence-unit>
|
||||
</persistence>
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.annotation.Action;
|
||||
import org.apache.isis.applib.annotation.DomainService;
|
||||
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
|
||||
)
|
||||
public class HomePageService {
|
||||
|
||||
//region > homePage (action)
|
||||
|
||||
@Action(
|
||||
semantics = SemanticsOf.SAFE
|
||||
)
|
||||
@HomePage
|
||||
public HomePageViewModel homePage() {
|
||||
return container.injectServicesInto(new HomePageViewModel());
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region > injected services
|
||||
|
||||
@javax.inject.Inject
|
||||
DomainObjectContainer container;
|
||||
|
||||
//endregion
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.isis.applib.annotation.ViewModel;
|
||||
|
||||
import domainapp.dom.modules.simple.SimpleObject;
|
||||
import domainapp.dom.modules.simple.SimpleObjects;
|
||||
|
||||
@ViewModel
|
||||
public class HomePageViewModel {
|
||||
|
||||
//region > title
|
||||
public String title() {
|
||||
return getObjects().size() + " objects";
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > object (collection)
|
||||
@org.apache.isis.applib.annotation.HomePage
|
||||
public List<SimpleObject> getObjects() {
|
||||
return simpleObjects.listAll();
|
||||
}
|
||||
//endregion
|
||||
|
||||
//region > injected services
|
||||
|
||||
@javax.inject.Inject
|
||||
SimpleObjects simpleObjects;
|
||||
|
||||
//endregion
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 12,
|
||||
"collections": {
|
||||
"objects": {
|
||||
"collectionLayout": {
|
||||
"render": "EAGERLY"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"actions": {}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 456 B |
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import javax.jdo.JDOHelper;
|
||||
import javax.jdo.annotations.IdentityType;
|
||||
import javax.jdo.annotations.VersionStrategy;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.Identifier;
|
||||
import org.apache.isis.applib.annotation.Action;
|
||||
import org.apache.isis.applib.annotation.BookmarkPolicy;
|
||||
import org.apache.isis.applib.annotation.DomainObject;
|
||||
import org.apache.isis.applib.annotation.DomainObjectLayout;
|
||||
import org.apache.isis.applib.annotation.Editing;
|
||||
import org.apache.isis.applib.annotation.Parameter;
|
||||
import org.apache.isis.applib.annotation.ParameterLayout;
|
||||
import org.apache.isis.applib.annotation.Property;
|
||||
import org.apache.isis.applib.annotation.Title;
|
||||
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.DatastoreIdentity(
|
||||
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"})
|
||||
@DomainObject
|
||||
@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());
|
||||
}
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
@Action(
|
||||
domainEvent = UpdateNameDomainEvent.class
|
||||
)
|
||||
public SimpleObject updateName(
|
||||
@Parameter(maxLength = 40)
|
||||
@ParameterLayout(named = "New name")
|
||||
final String name) {
|
||||
setName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String default0UpdateName() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
public TranslatableString validateUpdateName(final String name) {
|
||||
return name.contains("!")? TranslatableString.tr("Exclamation mark is not allowed"): null;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//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
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"span": 6,
|
||||
"memberGroups": {
|
||||
"General": {
|
||||
"members": {
|
||||
"name": {
|
||||
"actions": {
|
||||
"updateName": {
|
||||
"actionLayout": {
|
||||
"position": "BOTTOM"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"versionSequence": {
|
||||
"propertyLayout": {
|
||||
"name": "version"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 0,
|
||||
"memberGroups": {}
|
||||
},
|
||||
{
|
||||
"span": 6,
|
||||
"collections": {}
|
||||
}
|
||||
],
|
||||
"actions": {}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 653 B |
@ -0,0 +1,107 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.applib.Identifier;
|
||||
import org.apache.isis.applib.annotation.Action;
|
||||
import org.apache.isis.applib.annotation.ActionLayout;
|
||||
import org.apache.isis.applib.annotation.BookmarkPolicy;
|
||||
import org.apache.isis.applib.annotation.DomainService;
|
||||
import org.apache.isis.applib.annotation.DomainServiceLayout;
|
||||
import org.apache.isis.applib.annotation.MemberOrder;
|
||||
import org.apache.isis.applib.annotation.ParameterLayout;
|
||||
import org.apache.isis.applib.annotation.SemanticsOf;
|
||||
import org.apache.isis.applib.query.QueryDefault;
|
||||
import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
|
||||
import org.apache.isis.applib.services.i18n.TranslatableString;
|
||||
|
||||
@DomainService(repositoryFor = SimpleObject.class)
|
||||
@DomainServiceLayout(menuOrder = "10")
|
||||
public class SimpleObjects {
|
||||
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
//region > injected services
|
||||
|
||||
@javax.inject.Inject
|
||||
DomainObjectContainer container;
|
||||
|
||||
//endregion
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SimpleObjectTest {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.jmock.Expectations;
|
||||
import org.jmock.Sequence;
|
||||
import org.jmock.auto.Mock;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.isis.applib.DomainObjectContainer;
|
||||
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
|
||||
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SimpleObjectsTest {
|
||||
|
||||
@Rule
|
||||
public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
|
||||
|
||||
@Mock
|
||||
DomainObjectContainer mockContainer;
|
||||
|
||||
SimpleObjects simpleObjects;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
simpleObjects = new SimpleObjects();
|
||||
simpleObjects.container = mockContainer;
|
||||
}
|
||||
|
||||
public static class Create extends SimpleObjectsTest {
|
||||
|
||||
@Test
|
||||
public void happyCase() throws Exception {
|
||||
|
||||
// given
|
||||
final SimpleObject simpleObject = new SimpleObject();
|
||||
|
||||
final Sequence seq = context.sequence("create");
|
||||
context.checking(new Expectations() {
|
||||
{
|
||||
oneOf(mockContainer).newTransientInstance(SimpleObject.class);
|
||||
inSequence(seq);
|
||||
will(returnValue(simpleObject));
|
||||
|
||||
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 {
|
||||
|
||||
// given
|
||||
final List<SimpleObject> all = Lists.newArrayList();
|
||||
|
||||
context.checking(new Expectations() {
|
||||
{
|
||||
oneOf(mockContainer).allInstances(SimpleObject.class);
|
||||
will(returnValue(all));
|
||||
}
|
||||
});
|
||||
|
||||
// when
|
||||
final List<SimpleObject> list = simpleObjects.listAll();
|
||||
|
||||
// then
|
||||
assertThat(list).isEqualTo(all);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user