Skip to content

Commit

Permalink
Top level change to support multiple entities per file...
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbey committed Mar 6, 2024
1 parent 3071184 commit 0eaa253
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public class EntityMojo extends AbstractMojo
@Parameter(defaultValue = "${project.basedir}", readonly = true)
public File baseDir;

@Parameter(defaultValue = "true")
public boolean enforceOneEntityPerFile;

@Override
public void execute() throws MojoExecutionException
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
Association model::domain::associations::Employment
{
employer: model::domain::Firm[*];
employees: model::domain::Person[*];
}

Class model::domain::classes::Address
{
type: model::domain::enums::AddressType[1];
address: String[1];
}

Class model::domain::classes::EntityWithAddresses
{
addresses: model::domain::classes::Address[*];
}

Class model::domain::classes::Firm extends model::domain::classes::EntityWithAddresses
{
legalName: String[1];
commonName: String[0..1];
founded: StrictDate[0..1];
}

Class model::domain::classes::Person extends model::domain::classes::EntityWithAddresses
{
firstName: String[1];
lastName: String[1];
}

Enum model::domain::enums::AddressType
{
STREET, CITY, COUNTRY
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.finos.legend.sdlc.serialization;

import java.util.List;
import org.finos.legend.sdlc.domain.model.entity.Entity;
import org.finos.legend.sdlc.tools.entity.EntityPaths;

Expand Down Expand Up @@ -156,7 +157,7 @@ default Path filePathForEntity(Entity entity, Path rootDirectory, String extensi
* @return deserialized entity
* @throws IOException if an I/O error occurs
*/
Entity deserialize(InputStream stream) throws IOException;
List<Entity> deserialize(InputStream stream) throws IOException;

/**
* Deserialize an entity from a byte array.
Expand All @@ -165,7 +166,7 @@ default Path filePathForEntity(Entity entity, Path rootDirectory, String extensi
* @return deserialized entity
* @throws IOException if an I/O error occurs
*/
default Entity deserialize(byte[] content) throws IOException
default List<Entity> deserialize(byte[] content) throws IOException
{
return deserialize(new ByteArrayInputStream(content));
}
Expand Down

0 comments on commit 0eaa253

Please sign in to comment.