Skip to content

Commit

Permalink
removed identifiable from java classes + moved java packages directly…
Browse files Browse the repository at this point in the history
… under the java folder
  • Loading branch information
Frode Sjovatsen committed Aug 15, 2017
1 parent 4e09f49 commit 292107a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

rm -rf build

gox -output="./build/{{.OS}}/{{.Dir}}" -rebuild -osarch="darwin/amd64 windows/amd64"
gox -output="./build/{{.Dir}}-{{.OS}}" -rebuild -osarch="darwin/amd64 windows/amd64"
2 changes: 1 addition & 1 deletion common/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ package config
const JAVA_PACKAGE_BASE = "no.fint.model"
const NET_NAMESPACE_BASE = "FINT.Model"
const DEFAULT_TAG = "latest"
const JAVA_BASE_PATH = "java/src/main/java/"
const JAVA_BASE_PATH = "java"
const CS_BASE_PATH = "cs/"
16 changes: 11 additions & 5 deletions generate/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import (
"github.com/FINTprosjektet/fint-model/common/github"
"github.com/FINTprosjektet/fint-model/common/parser"
"github.com/FINTprosjektet/fint-model/namespaces"
"github.com/FINTprosjektet/fint-model/packages"
"github.com/codegangsta/cli"
"io/ioutil"
"os"
"strings"
"github.com/FINTprosjektet/fint-model/common/types"
"github.com/FINTprosjektet/fint-model/packages"
)

func CmdGenerate(c *cli.Context) {
Expand Down Expand Up @@ -50,7 +50,7 @@ func generateJavaCode(tag string, force bool) {
class := GetJavaClass(c)

path := fmt.Sprintf("%s/%s/%s.java", config.JAVA_BASE_PATH, strings.Replace(c.Package, ".", "/", -1), c.Name)
err := ioutil.WriteFile(path, []byte(class), 0777)
err := ioutil.WriteFile(removeJavaPackagePathFromFilePath(path), []byte(class), 0777)
if err != nil {
fmt.Printf("Unable to write file: %s", err)
}
Expand All @@ -62,7 +62,7 @@ func generateJavaCode(tag string, force bool) {
fmt.Printf(" > Creating action: %s.java\n", action.Name)
actionEnum := GetJavaActionEnum(action)
path := fmt.Sprintf("%s/%s/%s.java", config.JAVA_BASE_PATH, strings.Replace(p, ".", "/", -1), action.Name)
err := ioutil.WriteFile(path, []byte(actionEnum), 0777)
err := ioutil.WriteFile(removeJavaPackagePathFromFilePath(path), []byte(actionEnum), 0777)
if err != nil {
fmt.Printf("Unable to write file: %s", err)
}
Expand All @@ -71,6 +71,11 @@ func generateJavaCode(tag string, force bool) {

fmt.Println("Finish generating Java code!")
}

func removeJavaPackagePathFromFilePath(path string) string {
return strings.Replace(path, "no/fint/model/", "", -1)
}

func getAction(p string, cl []types.Class) types.Action {
var action types.Action

Expand Down Expand Up @@ -158,13 +163,14 @@ func setupJavaDirStructure(tag string, force bool) {
fmt.Println("Unable to create base structure")
fmt.Println(err)
}

for _, pkg := range packages.DistinctPackageList(tag, force) {
path := fmt.Sprintf("%s/%s", config.JAVA_BASE_PATH, strings.Replace(pkg, ".", "/", -1))
err := os.MkdirAll(path, 0777)
err := os.MkdirAll(removeJavaPackagePathFromFilePath(path), 0777)
if err != nil {
fmt.Println("Unable to create packages structure")
fmt.Println(err)
}

}

}
13 changes: 1 addition & 12 deletions generate/java_class_tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ package generate

const JAVA_CLASS_TEMPLATE = `package {{ .Package }};
{{ if .Identifiable }}
import com.fasterxml.jackson.annotation.JsonIgnore;
import no.fint.model.relation.Identifiable;
{{ end }}
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
Expand All @@ -25,7 +21,7 @@ import {{ $i }};
@NoArgsConstructor
@EqualsAndHashCode
{{ end -}}
public {{- if .Abstract }} abstract {{- end }} class {{ .Name }} {{ if .Extends -}} extends {{ .Extends }} {{ end -}} {{ if .Identifiable -}} implements Identifiable {{ end -}} {
public {{- if .Abstract }} abstract {{- end }} class {{ .Name }} {{ if .Extends -}} extends {{ .Extends }} {{ end -}} {
{{- if .Relations }}
{{ $c := sub (len .Relations) 1 -}}
Expand All @@ -40,13 +36,6 @@ public {{- if .Abstract }} abstract {{- end }} class {{ .Name }} {{ if .Extends
private {{ javaType $att.Type}} {{ $att.Name }};
{{ end -}}
{{ end -}}
{{ if .Identifiable }}
@JsonIgnore
@Override
public String getId() {
return this.getSystemId().getIdentifikatorverdi();
}
{{ end -}}
}
`
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

const Name string = "fint-model"
const Version string = "1.1.2"
const Version string = "1.2.0"

0 comments on commit 292107a

Please sign in to comment.