FINERACT-1926: Minor fixes with module static weaving

This commit is contained in:
Arnold Galovics
2023-05-16 21:43:54 +02:00
committed by Arnold Gálovics
parent da1aa9e5a8
commit 9fee79ecde
10 changed files with 210 additions and 4 deletions
+19
View File
@@ -23,6 +23,25 @@ apply plugin: 'eclipse'
check.dependsOn('cucumber')
compileJava.doLast {
def mainSS = sourceSets.main
def source = mainSS.java.classesDirectory.get()
copy {
from file("src/main/resources/jpa/investor/persistence.xml")
into "${source}/META-INF/"
}
javaexec {
description = 'Performs EclipseLink static weaving of entity classes'
def target = source
main 'org.eclipse.persistence.tools.weaving.jpa.StaticWeave'
args '-persistenceinfo', source, '-classpath', sourceSets.main.runtimeClasspath, source, target
classpath sourceSets.main.runtimeClasspath
}
delete {
delete "${source}/META-INF/persistence.xml"
}
}
// Configuration for Swagger documentation generation task
// https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin
import org.apache.tools.ant.filters.ReplaceTokens
@@ -33,7 +33,7 @@ import org.apache.commons.lang3.NotImplementedException;
import org.apache.fineract.infrastructure.security.service.PlatformUserRightsContext;
import org.springframework.stereotype.Component;
@Path("/external-asset-owners")
@Path("/v1/external-asset-owners")
@Component
@Tag(name = "External Asset Owners", description = "External Asset Owners")
@RequiredArgsConstructor
@@ -0,0 +1,87 @@
/**
* 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 org.apache.fineract.investor.domain;
import java.time.LocalDateTime;
import java.util.Optional;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import org.springframework.data.domain.Auditable;
/**
* This class is a copy paste from the fineract-provider module since EclipseLink not weaves the class properly if it's
* placed in the fineract-core module.
*/
@MappedSuperclass
public abstract class AbstractAuditableCustom extends AbstractPersistableCustom implements Auditable<Long, Long, LocalDateTime> {
private static final long serialVersionUID = 141481953116476081L;
@Column(name = "createdby_id")
private Long createdBy;
@Column(name = "created_date")
private LocalDateTime createdDate;
@Column(name = "lastmodifiedby_id")
private Long lastModifiedBy;
@Column(name = "lastmodified_date")
private LocalDateTime lastModifiedDate;
@Override
public Optional<Long> getCreatedBy() {
return Optional.ofNullable(this.createdBy);
}
@Override
public void setCreatedBy(final Long createdBy) {
this.createdBy = createdBy;
}
@Override
public Optional<LocalDateTime> getCreatedDate() {
return null == this.createdDate ? Optional.empty() : Optional.of(this.createdDate);
}
@Override
public void setCreatedDate(final LocalDateTime createdDate) {
this.createdDate = createdDate;
}
@Override
public Optional<Long> getLastModifiedBy() {
return Optional.ofNullable(this.lastModifiedBy);
}
@Override
public void setLastModifiedBy(final Long lastModifiedBy) {
this.lastModifiedBy = lastModifiedBy;
}
@Override
public Optional<LocalDateTime> getLastModifiedDate() {
return null == this.lastModifiedDate ? Optional.empty() : Optional.of(this.lastModifiedDate);
}
@Override
public void setLastModifiedDate(final LocalDateTime lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
}
@@ -0,0 +1,62 @@
/**
* 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 org.apache.fineract.investor.domain;
import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PostLoad;
import javax.persistence.PrePersist;
import javax.persistence.Transient;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.data.domain.Persistable;
/**
* This class is a copy paste from the fineract-provider module since EclipseLink not weaves the class properly if it's
* placed in the fineract-core module.
*/
@MappedSuperclass
@Getter
@Setter
@NoArgsConstructor
public abstract class AbstractPersistableCustom implements Persistable<Long>, Serializable {
private static final long serialVersionUID = 9181640245194392646L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Getter(onMethod = @__(@Override))
private Long id;
@Transient
@Setter(value = AccessLevel.NONE)
@Getter(onMethod = @__(@Override))
private boolean isNew = true;
@PrePersist
@PostLoad
void markNotNew() {
this.isNew = false;
}
}
@@ -25,7 +25,6 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
@Getter
@Setter
@@ -27,7 +27,6 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
@Getter
@Setter
@@ -25,7 +25,6 @@ import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
@Getter
@Setter
@@ -0,0 +1,37 @@
<?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 version="2.0"
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_2_0.xsd">
<!-- This file is only used for static weaving, nothing more. -->
<!-- You can find the runtime configuration in the JPAConfig class -->
<persistence-unit name="jpa-pu" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.weaving" value="static" />
</properties>
</persistence-unit>
</persistence>
@@ -26,6 +26,8 @@ import org.springframework.data.domain.Auditable;
import org.springframework.data.jpa.domain.AbstractAuditable;
/**
* Make sure to modify the same class in the modules (fineract-investor, etc)
*
* A custom copy of {@link AbstractAuditable} to override the column names used on database. It also uses Instant
* instead of LocalDateTime for created and modified.
*
@@ -33,6 +33,8 @@ import lombok.Setter;
import org.springframework.data.domain.Persistable;
/**
* Make sure to modify the same class in the modules (fineract-investor, etc)
*
* Abstract base class for entities.
*
* Inspired by {@link org.springframework.data.jpa.domain.AbstractPersistable}, but Id is always Long (and this class