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
}