Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
fix: fix lost repo for resoruce issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 24, 2022
1 parent be834fa commit 40e88b8
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.thoughtworks.archguard.scanner.sourcecode

import com.thoughtworks.archguard.scanner.sourcecode.frontend.ContainerDemand
import com.thoughtworks.archguard.scanner.sourcecode.frontend.ContainerResource
import com.thoughtworks.archguard.scanner.sourcecode.frontend.ContainerService
import infrastructure.SourceBatch
import java.util.HashMap
Expand All @@ -21,6 +22,7 @@ class ContainerRepository(systemId: String, language: String, workspace: String)
val serviceId = saveMainServices()
services.forEach { caller ->
caller.demands.map { saveDemand(it, serviceId, caller.name) }.toTypedArray()
caller.resources.map { saveResource(it, serviceId, caller.name) }.toTypedArray()
}
}

Expand Down Expand Up @@ -48,6 +50,31 @@ class ContainerRepository(systemId: String, language: String, workspace: String)
return serviceId
}


private fun saveResource(it: ContainerResource, serviceId: String, name: String): String {
val time: String = ClassRepository.currentTime
val resourceId = ClassRepository.generateId()
val values: MutableMap<String, String> = HashMap()

values["id"] = resourceId
values["serviceId"] = serviceId

values["source_url"] = it.sourceUrl
values["source_http_method"] = it.sourceHttpMethod

values["package_name"] = it.packageName
values["class_name"] = it.className
values["method_name"] = it.methodName

values["updated_at"] = time
values["created_at"] = time
values["created_by"] = "scanner"

batch.add("container_resource", values)
return resourceId
}


private fun saveDemand(demand: ContainerDemand, serviceId: String, name: String): String {
val time: String = ClassRepository.currentTime
val demandId = ClassRepository.generateId()
Expand Down

0 comments on commit 40e88b8

Please sign in to comment.